Skip to content

Commit

Permalink
Merge pull request #807 from eslavich/eslavich-remove-jsonschema-2-su…
Browse files Browse the repository at this point in the history
…pport

Remove jsonschema 2.x support and update minimal dependencies
  • Loading branch information
eslavich authored May 27, 2020
2 parents 0c73fc7 + 3c23e0c commit ad141da
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- Improve warning message when falling back to an older schema,
and note that fallback behavior will be removed in 3.0. [#806]

- Drop support for jsonschema 2.x. [#807]

2.6.1 (unreleased)
------------------

Expand Down
7 changes: 0 additions & 7 deletions asdf/compat/jsonschemacompat.py

This file was deleted.

34 changes: 12 additions & 22 deletions asdf/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from . import reference
from . import treeutil
from . import util
from .compat.jsonschemacompat import JSONSCHEMA_LT_3
from . import extension
from .exceptions import AsdfDeprecationWarning, AsdfWarning

Expand Down Expand Up @@ -249,29 +248,20 @@ def _make_seen_key(self, instance, schema):
def _create_validator(validators=YAML_VALIDATORS, visit_repeat_nodes=False):
meta_schema = _load_schema_cached(YAML_SCHEMA_METASCHEMA_ID, extension.get_default_resolver(), False, False)

if JSONSCHEMA_LT_3:
base_cls = mvalidators.create(meta_schema=meta_schema, validators=validators)
else:
type_checker = mvalidators.Draft4Validator.TYPE_CHECKER.redefine_many({
'array': lambda checker, instance: isinstance(instance, list) or isinstance(instance, tuple),
'integer': lambda checker, instance: not isinstance(instance, bool) and isinstance(instance, Integral),
'string': lambda checker, instance: isinstance(instance, (str, np.str_)),
})
id_of = mvalidators.Draft4Validator.ID_OF
base_cls = mvalidators.create(
meta_schema=meta_schema,
validators=validators,
type_checker=type_checker,
id_of=id_of
)
type_checker = mvalidators.Draft4Validator.TYPE_CHECKER.redefine_many({
'array': lambda checker, instance: isinstance(instance, list) or isinstance(instance, tuple),
'integer': lambda checker, instance: not isinstance(instance, bool) and isinstance(instance, Integral),
'string': lambda checker, instance: isinstance(instance, (str, np.str_)),
})
id_of = mvalidators.Draft4Validator.ID_OF
base_cls = mvalidators.create(
meta_schema=meta_schema,
validators=validators,
type_checker=type_checker,
id_of=id_of
)

class ASDFValidator(base_cls):
if JSONSCHEMA_LT_3:
DEFAULT_TYPES = base_cls.DEFAULT_TYPES.copy()
DEFAULT_TYPES['array'] = (list, tuple)
DEFAULT_TYPES['integer'] = (Integral)
DEFAULT_TYPES['string'] = (str, np.str_)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._context = _ValidationContext()
Expand Down
12 changes: 4 additions & 8 deletions docs/asdf/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Requirements

The ``asdf`` package has the following dependencies:

- `python <https://www.python.org/>`__ 3.3 or later
- `python <https://www.python.org/>`__ 3.5 or later

- `numpy <https://www.numpy.org/>`__ 1.8 or later
- `numpy <https://www.numpy.org/>`__ 1.10 or later

- `jsonschema <https://python-jsonschema.readthedocs.io/>`__ 2.3.0 or later
- `jsonschema <https://python-jsonschema.readthedocs.io/>`__ 3.0.2 or later

- `pyyaml <https://pyyaml.org>`__ 3.10 or later

- `semantic_version <https://python-semanticversion.readthedocs.io/>`__ 2.3.1 or later
- `semantic_version <https://python-semanticversion.readthedocs.io/>`__ 2.8 or later

Support for units, time, transform, wcs, or running the tests also
requires:
Expand All @@ -32,10 +32,6 @@ compression is provided by:

- `lz4 <https://python-lz4.readthedocs.io/>`__ 0.10 or later

Also required for running the tests:

- `pytest-astropy <https://github.com/astropy/pytest-astropy>`__

Installing with pip
===================

Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ include_package_data = True
install_requires =
semantic_version>=2.8
pyyaml>=3.10
jsonschema>=2.3,<4
numpy>=1.8
jsonschema>=3.0.2,<4
numpy>=1.10
[options.extras_require]
all =
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ deps=
# isn't compatible with the older versions of numpy
# that we test with.
py35,py36: gwcs==0.9.1
legacy: semantic_version==2.3.1
legacy: semantic_version==2.8
legacy: pyyaml==3.10
legacy: jsonschema==2.3
legacy: jsonschema==3.0.2
legacy: numpy~=1.10.0
numpy11,numpy12,legacy: astropy~=3.0.0
numpy11: numpy==1.11
Expand Down

0 comments on commit ad141da

Please sign in to comment.