Skip to content

Commit

Permalink
Update to jsonschema > 4.18, Sphinx < 7 (#572)
Browse files Browse the repository at this point in the history
* Update to jsonschema > 4.18

* Try Sphinx < 7
  • Loading branch information
HGSilveri authored Aug 29, 2023
1 parent 0d8d4b1 commit f742f5c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# For generating documentation.
Sphinx
Sphinx < 7
sphinx-rtd-theme # documentation theme
sphinx_autodoc_typehints == 1.21.3
nbsphinx
Expand Down
10 changes: 5 additions & 5 deletions pulser-core/pulser/json/abstract_repr/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from typing import Literal

import jsonschema
from referencing import Registry, Resource

from pulser.json.abstract_repr import SCHEMAS, SCHEMAS_PATH
from pulser.json.abstract_repr import SCHEMAS

RESOLVER = jsonschema.validators.RefResolver(
base_uri=f"{SCHEMAS_PATH.resolve().as_uri()}/",
referrer=SCHEMAS["sequence"],
REGISTRY: Registry = Registry().with_resources(
[("device-schema.json", Resource.from_contents(SCHEMAS["device"]))]
)


Expand All @@ -37,5 +37,5 @@ def validate_abstract_repr(
obj = json.loads(obj_str)
validate_args = dict(instance=obj, schema=SCHEMAS[name])
if name == "sequence":
validate_args["resolver"] = RESOLVER
validate_args["registry"] = REGISTRY
jsonschema.validate(**validate_args)
2 changes: 1 addition & 1 deletion pulser-core/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonschema < 4.18
jsonschema >= 4.18
matplotlib
# Numpy 1.20 introduces type hints, 1.24.0 breaks matplotlib < 3.6.1
numpy >= 1.20, != 1.24.0
Expand Down
4 changes: 2 additions & 2 deletions tests/test_abstract_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
AbstractReprEncoder,
abstract_repr,
)
from pulser.json.abstract_repr.validation import RESOLVER
from pulser.json.abstract_repr.validation import REGISTRY
from pulser.json.exceptions import AbstractReprError, DeserializeDeviceError
from pulser.parametrized.decorators import parametrize
from pulser.parametrized.paramobj import ParamObj
Expand Down Expand Up @@ -282,7 +282,7 @@ def validate_schema(instance):
"pulser-core/pulser/json/abstract_repr/schemas/" "sequence-schema.json"
) as f:
schema = json.load(f)
jsonschema.validate(instance=instance, schema=schema, resolver=RESOLVER)
jsonschema.validate(instance=instance, schema=schema, registry=REGISTRY)


class TestSerialization:
Expand Down

0 comments on commit f742f5c

Please sign in to comment.