Skip to content

Commit

Permalink
Fix incompatibility with jsonschema < 4.5 (#2860)
Browse files Browse the repository at this point in the history
* Fix incompatibility with jsonschema < 4.17

* Add changelog entry for 4.2.2

* Fix jsonschema version in changelog
  • Loading branch information
binste committed Jan 27, 2023
1 parent 9853f65 commit 4e18031
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions altair/utils/schemapi.py
Expand Up @@ -50,9 +50,10 @@ def validate_jsonschema(spec, schema, resolver=None):
# e.g. '#/definitions/ValueDefWithCondition<MarkPropFieldOrDatumDef,
# (Gradient|string|null)>' would be a valid $ref in a Vega-Lite schema but
# it is not a valid URI reference due to the characters such as '<'.
validator = JSONSCHEMA_VALIDATOR(
schema, format_checker=JSONSCHEMA_VALIDATOR.FORMAT_CHECKER, resolver=resolver
)
validator_kwargs = {"resolver": resolver}
if hasattr(JSONSCHEMA_VALIDATOR, "FORMAT_CHECKER"):
validator_kwargs["format_checker"] = JSONSCHEMA_VALIDATOR.FORMAT_CHECKER
validator = JSONSCHEMA_VALIDATOR(schema, **validator_kwargs)
error = jsonschema.exceptions.best_match(validator.iter_errors(spec))
if error is not None:
raise error
Expand Down
7 changes: 7 additions & 0 deletions doc/releases/changes.rst
Expand Up @@ -3,6 +3,13 @@
Altair Change Log
=================

Version 4.2.2 (released XXX YY, 2023)
-------------------------------------

Bug Fixes
~~~~~~~~~
- Fix incompatibility with jsonschema < 4.5 which got introduced in Altair 4.2.1 (#2860).

Version 4.2.1 (released Jan 26, 2023)
-------------------------------------

Expand Down
7 changes: 4 additions & 3 deletions tools/schemapi/schemapi.py
Expand Up @@ -48,9 +48,10 @@ def validate_jsonschema(spec, schema, resolver=None):
# e.g. '#/definitions/ValueDefWithCondition<MarkPropFieldOrDatumDef,
# (Gradient|string|null)>' would be a valid $ref in a Vega-Lite schema but
# it is not a valid URI reference due to the characters such as '<'.
validator = JSONSCHEMA_VALIDATOR(
schema, format_checker=JSONSCHEMA_VALIDATOR.FORMAT_CHECKER, resolver=resolver
)
validator_kwargs = {"resolver": resolver}
if hasattr(JSONSCHEMA_VALIDATOR, "FORMAT_CHECKER"):
validator_kwargs["format_checker"] = JSONSCHEMA_VALIDATOR.FORMAT_CHECKER
validator = JSONSCHEMA_VALIDATOR(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 4e18031

Please sign in to comment.