From 8368fd28423e8173041a726b797ea500ade70c9b Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 7 Aug 2023 09:19:52 -0400 Subject: [PATCH 1/2] drop jsonschema as a dependency --- CHANGES.rst | 1 + asdf/_jsonschema/exceptions.py | 41 +++++++++++++--------------------- docs/asdf/config.rst | 2 +- pyproject.toml | 2 -- requirements-dev.txt | 2 -- 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ee831be6a..77e71c024 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -38,6 +38,7 @@ The ASDF Standard is at v1.6.0 - Convert numpy scalars to python types during yaml encoding to handle NEP51 changes for numpy 2.0 [#1605] - Vendorize jsonschema 4.17.3 [#1591] +- Drop jsonschema as a dependency [#1614] 2.15.0 (2023-03-28) ------------------- diff --git a/asdf/_jsonschema/exceptions.py b/asdf/_jsonschema/exceptions.py index c19d3a27a..7114167c7 100644 --- a/asdf/_jsonschema/exceptions.py +++ b/asdf/_jsonschema/exceptions.py @@ -17,10 +17,7 @@ WEAK_MATCHES: frozenset[str] = frozenset(["anyOf", "oneOf"]) STRONG_MATCHES: frozenset[str] = frozenset() -try: - from jsonschema.exceptions import _unset -except ImportError: - _unset = _utils.Unset() +_unset = _utils.Unset() class _Error(Exception): @@ -161,16 +158,13 @@ def _matches_type(self): ) -try: - from jsonschema import ValidationError -except ImportError: - class ValidationError(_Error): - """ - An instance was invalid under a provided schema. - """ +class ValidationError(_Error): + """ + An instance was invalid under a provided schema. + """ - _word_for_schema_in_error_message = "schema" - _word_for_instance_in_error_message = "instance" + _word_for_schema_in_error_message = "schema" + _word_for_instance_in_error_message = "instance" class SchemaError(_Error): @@ -182,21 +176,16 @@ class SchemaError(_Error): _word_for_instance_in_error_message = "schema" -try: - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - from jsonschema import RefResolutionError -except ImportError: - @attr.s(hash=True) - class RefResolutionError(Exception): - """ - A ref could not be resolved. - """ +@attr.s(hash=True) +class RefResolutionError(Exception): + """ + A ref could not be resolved. + """ - _cause = attr.ib() + _cause = attr.ib() - def __str__(self): - return str(self._cause) + def __str__(self): + return str(self._cause) class UndefinedTypeCheck(Exception): diff --git a/docs/asdf/config.rst b/docs/asdf/config.rst index d3b85092a..b4bfd9834 100644 --- a/docs/asdf/config.rst +++ b/docs/asdf/config.rst @@ -232,7 +232,7 @@ a schema, which can then be used to validate a file: >>> af.validate() Traceback (most recent call last): ... - jsonschema.exceptions.ValidationError: 'foo' is a required property + asdf.exceptions.ValidationError: 'foo' is a required property ... >>> af["foo"] = "bar" >>> af.validate() diff --git a/pyproject.toml b/pyproject.toml index 28f281a6b..1834068f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,8 +31,6 @@ dependencies = [ # for vendorized jsonschema "attrs>=20.1.0", # end of vendorized jsonschema deps - # include jsonschema for all the downstream packages expecting us to provide this - "jsonschema>=4.8", ] [project.optional-dependencies] all = [ diff --git a/requirements-dev.txt b/requirements-dev.txt index 658447c10..82af43cfc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,8 +6,6 @@ git+https://github.com/asdf-format/asdf-unit-schemas.git git+https://github.com/asdf-format/asdf-wcs-schemas git+https://github.com/astropy/astropy #git+https://github.com/yaml/pyyaml.git -# jsonschema 4.18 contains incompatible changes: https://github.com/asdf-format/asdf/issues/1485 -#git+https://github.com/python-jsonschema/jsonschema numpy>=0.0.dev0 scipy>=0.0.dev0 From dca4f216685df9f4f559da3daf19158b428f8618 Mon Sep 17 00:00:00 2001 From: Brett Date: Tue, 15 Aug 2023 12:16:46 -0400 Subject: [PATCH 2/2] fix doctest --- docs/asdf/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/asdf/config.rst b/docs/asdf/config.rst index b4bfd9834..9476c5466 100644 --- a/docs/asdf/config.rst +++ b/docs/asdf/config.rst @@ -232,7 +232,7 @@ a schema, which can then be used to validate a file: >>> af.validate() Traceback (most recent call last): ... - asdf.exceptions.ValidationError: 'foo' is a required property + asdf._jsonschema.exceptions.ValidationError: 'foo' is a required property ... >>> af["foo"] = "bar" >>> af.validate()