Skip to content

Commit

Permalink
build: Upgrade jsonref
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 28, 2022
1 parent cc149c3 commit 742e910
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions jscc/testing/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_schema_valid(path, name, data):
.. code-block:: python
from jsonref import JsonRef
import jsonref
from jscc.schema import (validate_array_items, validate_codelist_enum, validate_deep_properties,
validate_items_type, validate_letter_case, validate_merge_properties,
validate_metadata_presence, validate_null_type, validate_object_id, validate_ref,
Expand All @@ -42,7 +42,7 @@ def validate_json_schema(path, name, data, schema):
errors += validate_merge_properties(path, data)
errors += validate_ref(path, data)
errors += validate_metadata_presence(path, data)
errors += validate_object_id(path, JsonRef.replace_refs(data))
errors += validate_object_id(path, jsonref.replace_refs(data))
errors += validate_null_type(path, data)
# Here, we don't add to `errors`, in order to not count these warnings as errors.
validate_deep_properties(path, data)
Expand Down Expand Up @@ -79,7 +79,7 @@ def formatwarning(message, category, filename, lineno, line=None):
import re
from warnings import warn

from jsonref import JsonRef, JsonRefError
import jsonref
from jsonschema import FormatChecker
from jsonschema.validators import Draft4Validator as validator

Expand Down Expand Up @@ -661,12 +661,9 @@ def validate_ref(path, data):
:returns: ``0`` or ``1``
:rtype: int
"""
ref = JsonRef.replace_refs(data)

try:
# `repr` causes the references to be loaded, if possible.
repr(ref)
except JsonRefError as e:
jsonref.replace_refs(data, lazy_load=False)
except jsonref.JsonRefError as e:
warn(f"{path} has {e.message} at {'/'.join(map(str, e.path))}", RefWarning)
return 1

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
long_description_content_type='text/x-rst',
install_requires=[
'json-merge-patch',
'jsonref',
'jsonref>=1',
'jsonschema',
'requests',
'rfc3339-validator',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import os
import warnings

import jsonref
import pytest
from jsonref import JsonRef

import jscc.testing.checks
from jscc.exceptions import DuplicateKeyError
Expand Down Expand Up @@ -223,7 +223,7 @@ def allow_missing(pointer):

filepath = os.path.join('schema', 'object_id.json')
with pytest.warns(UserWarning) as records:
errors = validate_object_id(path(filepath), JsonRef.replace_refs(parse(filepath)), allow_missing=allow_missing,
errors = validate_object_id(path(filepath), jsonref.replace_refs(parse(filepath)), allow_missing=allow_missing,
allow_optional='/properties/allowOptional')

assert sorted(str(record.message) for record in records) == [
Expand Down

0 comments on commit 742e910

Please sign in to comment.