Skip to content

Commit

Permalink
Fix regression introduced in vega#2771 for older jsonschema versions …
Browse files Browse the repository at this point in the history
…which did not yet make format checker accessible on validator class
  • Loading branch information
binste committed Jan 7, 2023
1 parent c7f5f82 commit 29ad5e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions altair/utils/schemapi.py
Expand Up @@ -62,9 +62,10 @@ def validate_jsonschema(spec, schema, rootschema=None):
# No resolver is necessary if the schema is already the full schema
resolver = None

validator = validator_cls(
schema, format_checker=validator_cls.FORMAT_CHECKER, resolver=resolver
)
validator_kwargs = {"resolver": resolver}
if hasattr(validator_cls, "FORMAT_CHECKER"):
validator_kwargs["format_checker"] = validator_cls.FORMAT_CHECKER
validator = validator_cls(schema, **validator_kwargs)
error = jsonschema.exceptions.best_match(validator.iter_errors(spec))
if error is not None:
raise error
Expand Down
7 changes: 4 additions & 3 deletions tools/schemapi/schemapi.py
Expand Up @@ -60,9 +60,10 @@ def validate_jsonschema(spec, schema, rootschema=None):
# No resolver is necessary if the schema is already the full schema
resolver = None

validator = validator_cls(
schema, format_checker=validator_cls.FORMAT_CHECKER, resolver=resolver
)
validator_kwargs = {"resolver": resolver}
if hasattr(validator_cls, "FORMAT_CHECKER"):
validator_kwargs["format_checker"] = validator_cls.FORMAT_CHECKER
validator = validator_cls(schema, **validator_kwargs)
error = jsonschema.exceptions.best_match(validator.iter_errors(spec))
if error is not None:
raise error
Expand Down

0 comments on commit 29ad5e9

Please sign in to comment.