Skip to content

Commit

Permalink
use types-jsonschema
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored and branchvincent committed May 21, 2022
1 parent 504eb96 commit 80b03ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ flatdict = "^4.0.1"
mypy = ">=0.950"
types-entrypoints = ">=0.3.7"
types-html5lib = ">=1.1.7"
types-jsonschema = ">=4.4.4"
types-requests = ">=2.27.11"

[tool.poetry.scripts]
Expand Down Expand Up @@ -142,7 +143,6 @@ module = [
'cachy.*',
'cleo.*',
'crashtest.*',
'jsonschema.*',
'pexpect.*',
'pkginfo.*',
'poetry.core.*',
Expand Down
6 changes: 3 additions & 3 deletions src/poetry/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class ValidationError(ValueError):


def validate_object(obj: dict[str, Any], schema_name: str) -> list[str]:
schema = os.path.join(SCHEMA_DIR, f"{schema_name}.json")
schema_file = os.path.join(SCHEMA_DIR, f"{schema_name}.json")

if not os.path.exists(schema):
if not os.path.exists(schema_file):
raise ValueError(f"Schema {schema_name} does not exist.")

with open(schema, encoding="utf-8") as f:
with open(schema_file, encoding="utf-8") as f:
schema = json.loads(f.read())

validator = jsonschema.Draft7Validator(schema)
Expand Down

0 comments on commit 80b03ec

Please sign in to comment.