Skip to content

Commit

Permalink
Migrate from RefResolver to referencing library
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoyer committed Aug 27, 2024
1 parent f4fb82e commit 28e5bdb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ docs/_build
docs/spec
docs/stories
__pycache__
venv
.venv
8 changes: 5 additions & 3 deletions fmf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import jsonschema
from filelock import FileLock, Timeout
from referencing import Registry
from referencing.jsonschema import DRAFT4
from ruamel.yaml import YAML, scalarstring
from ruamel.yaml.comments import CommentedMap

Expand Down Expand Up @@ -934,12 +936,12 @@ def validate_data(data, schema, schema_store=None):
"""
schema_store = schema_store or {}
try:
resolver = jsonschema.RefResolver.from_schema(
schema, store=schema_store)
registry = Registry().with_resource(schema_store, DRAFT4.create_resource()
)
except AttributeError as error:
raise JsonSchemaError(f'Provided schema cannot be loaded: {error}')

validator = jsonschema.Draft4Validator(schema, resolver=resolver)
validator = jsonschema.Draft4Validator(schema, registry=registry)

try:
validator.validate(data)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'ruamel.yaml',
'filelock',
'jsonschema',
'referencing',
]
extras_require = {
'docs': ['sphinx==7.2.4', 'sphinx-rtd-theme==1.3.0'],
Expand Down

0 comments on commit 28e5bdb

Please sign in to comment.