Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Migrate from RefResolver to referencing library #253

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 4 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,11 @@ 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(schema))
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
Loading