Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-jsonschema for openSUSE:Factory checked in at 2023-07-14 15:35:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jsonschema (Old) and /work/SRC/openSUSE:Factory/.python-jsonschema.new.3193 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jsonschema" Fri Jul 14 15:35:46 2023 rev:39 rq:1098666 version:4.18.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-jsonschema/python-jsonschema.changes 2023-07-07 15:46:00.823728926 +0200 +++ /work/SRC/openSUSE:Factory/.python-jsonschema.new.3193/python-jsonschema.changes 2023-07-14 15:35:49.802002021 +0200 @@ -1,0 +2,21 @@ +Fri Jul 14 05:28:43 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- upgrade to 4.18.3: + no changelog available, only a diff: + https://github.com/python-jsonschema/jsonschema/compare/v4.18.2...v4.18.3 + +------------------------------------------------------------------- +Thu Jul 13 04:52:36 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- upgrade to 4.18.2: + * Fix an additional regression with the deprecated + jsonschema.RefResolver and pointer resolution. + +------------------------------------------------------------------- +Wed Jul 12 10:39:42 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- upgrade to 4.18.1: + * Fix a regression with jsonschema.RefResolver based resolution + when used in combination with a custom validation dialect (via + jsonschema.validators.create). +------------------------------------------------------------------- Old: ---- jsonschema-4.18.0.tar.gz New: ---- jsonschema-4.18.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jsonschema.spec ++++++ --- /var/tmp/diff_new_pack.8SUZCi/_old 2023-07-14 15:35:50.462005859 +0200 +++ /var/tmp/diff_new_pack.8SUZCi/_new 2023-07-14 15:35:50.466005883 +0200 @@ -33,7 +33,7 @@ %{?sle15_python_module_pythons} Name: python-jsonschema%{psuffix} -Version: 4.18.0 +Version: 4.18.3 Release: 0 Summary: An implementation of JSON-Schema validation for Python License: MIT ++++++ jsonschema-4.18.0.tar.gz -> jsonschema-4.18.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/.github/workflows/ci.yml new/jsonschema-4.18.3/.github/workflows/ci.yml --- old/jsonschema-4.18.0/.github/workflows/ci.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/.github/workflows/ci.yml 2020-02-02 01:00:00.000000000 +0100 @@ -58,8 +58,6 @@ posargs: coverage github exclude: - os: windows-latest - noxenv: readme - - os: windows-latest noxenv: "docs(dirhtml)" - os: windows-latest noxenv: "docs(doctest)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/.pre-commit-config.yaml new/jsonschema-4.18.3/.pre-commit-config.yaml --- old/jsonschema-4.18.0/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 @@ -16,7 +16,7 @@ args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.276" + rev: "v0.0.277" hooks: - id: ruff - repo: https://github.com/PyCQA/isort @@ -24,7 +24,7 @@ hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.9-for-vscode" + rev: "v3.0.0" hooks: - id: prettier exclude: "^jsonschema/benchmarks/issue232/issue.json$" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/CHANGELOG.rst new/jsonschema-4.18.3/CHANGELOG.rst --- old/jsonschema-4.18.0/CHANGELOG.rst 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/CHANGELOG.rst 2020-02-02 01:00:00.000000000 +0100 @@ -1,7 +1,23 @@ +v4.18.3 +======= + +* Properly preserve ``applicable_validators`` in extended validators. + Specifically, validators extending early drafts where siblings of ``$ref`` were ignored will properly ignore siblings in the extended validator. + +v4.18.2 +======= + +* Fix an additional regression with the deprecated ``jsonschema.RefResolver`` and pointer resolution. + +v4.18.1 +======= + +* Fix a regression with ``jsonschema.RefResolver`` based resolution when used in combination with a custom validation dialect (via ``jsonschema.validators.create``). + v4.18.0 ======= -This release majorly rehaul's the way in which JSON Schema reference resolution is configured. +This release majorly rehauls the way in which JSON Schema reference resolution is configured. It does so in a way that *should* be backwards compatible, preserving old behavior whilst emitting deprecation warnings. * ``jsonschema.RefResolver`` is now deprecated in favor of the new `referencing library <https://github.com/python-jsonschema/referencing/>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/PKG-INFO new/jsonschema-4.18.3/PKG-INFO --- old/jsonschema-4.18.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: jsonschema -Version: 4.18.0 +Version: 4.18.3 Summary: An implementation of JSON Schema validation for Python Project-URL: Homepage, https://github.com/python-jsonschema/jsonschema Project-URL: Documentation, https://python-jsonschema.readthedocs.io/ @@ -168,31 +168,8 @@ Release Information ------------------- -v4.18.0 +v4.18.3 ======= -This release majorly rehaul's the way in which JSON Schema reference resolution is configured. -It does so in a way that *should* be backwards compatible, preserving old behavior whilst emitting deprecation warnings. - -* ``jsonschema.RefResolver`` is now deprecated in favor of the new `referencing library <https://github.com/python-jsonschema/referencing/>`_. - ``referencing`` will begin in beta, but already is more compliant than the existing ``$ref`` support. - This change is a culmination of a meaningful chunk of work to make ``$ref`` resolution more flexible and more correct. - Backwards compatibility *should* be preserved for existing code which uses ``RefResolver``, though doing so is again now deprecated, and all such use cases should be doable using the new APIs. - Please file issues on the ``referencing`` tracker if there is functionality missing from it, or here on the ``jsonschema`` issue tracker if you have issues with existing code not functioning the same, or with figuring out how to change it to use ``referencing``. - In particular, this referencing change includes a change concerning *automatic* retrieval of remote references (retrieving ``http://foo/bar`` automatically within a schema). - This behavior has always been a potential security risk and counter to the recommendations of the JSON Schema specifications; it has survived this long essentially only for backwards compatibility reasons, and now explicitly produces warnings. - The ``referencing`` library itself will *not* automatically retrieve references if you interact directly with it, so the deprecated behavior is only triggered if you fully rely on the default ``$ref`` resolution behavior and also include remote references in your schema, which will still be retrieved during the deprecation period (after which they will become an error). -* Support for Python 3.7 has been dropped, as it is nearing end-of-life. - This should not be a "visible" change in the sense that ``requires-python`` has been updated, so users using 3.7 should still receive ``v4.17.3`` when installing the library. -* On draft 2019-09, ``unevaluatedItems`` now properly does *not* consider items to be evaluated by an ``additionalItems`` schema if ``items`` is missing from the schema, as the specification says in this case that ``additionalItems`` must be completely ignored. -* Fix the ``date`` format checker on Python 3.11 (when format assertion behavior is enabled), where it was too liberal (#1076). -* Speed up validation of ``unevaluatedProperties`` (#1075). - -Deprecations ------------- - -* ``jsonschema.RefResolver`` -- see above for details on the replacement -* ``jsonschema.RefResolutionError`` -- see above for details on the replacement -* relying on automatic resolution of remote references -- see above for details on the replacement -* importing ``jsonschema.ErrorTree`` -- instead import it via ``jsonschema.exceptions.ErrorTree`` -* importing ``jsonschema.FormatError`` -- instead import it via ``jsonschema.exceptions.FormatError`` +* Properly preserve ``applicable_validators`` in extended validators. + Specifically, validators extending early drafts where siblings of ``$ref`` were ignored will properly ignore siblings in the extended validator. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/jsonschema/_types.py new/jsonschema-4.18.3/jsonschema/_types.py --- old/jsonschema-4.18.0/jsonschema/_types.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/jsonschema/_types.py 2020-02-02 01:00:00.000000000 +0100 @@ -3,13 +3,13 @@ from typing import Any, Callable, Mapping import numbers +from attrs import evolve, field, frozen from rpds import HashTrieMap -import attr from jsonschema.exceptions import UndefinedTypeCheck -# unfortunately, the type of HashTrieMap is generic, and if used as the attr.ib +# unfortunately, the type of HashTrieMap is generic, and if used as an attrs # converter, the generic type is presented to mypy, which then fails to match # the concrete type of a type checker mapping # this "do nothing" wrapper presents the correct information to mypy @@ -57,7 +57,7 @@ return True -@attr.s(frozen=True, repr=False) +@frozen(repr=False) class TypeChecker: """ A :kw:`type` property checker. @@ -80,10 +80,7 @@ _type_checkers: HashTrieMap[ str, Callable[[TypeChecker, Any], bool], - ] = attr.ib( - default=HashTrieMap(), - converter=_typed_map_converter, - ) + ] = field(default=HashTrieMap(), converter=_typed_map_converter) def __repr__(self): types = ", ".join(repr(k) for k in sorted(self._type_checkers)) @@ -146,7 +143,7 @@ A dictionary mapping types to their checking functions. """ type_checkers = self._type_checkers.update(definitions) - return attr.evolve(self, type_checkers=type_checkers) + return evolve(self, type_checkers=type_checkers) def remove(self, *types) -> TypeChecker: """ @@ -170,7 +167,7 @@ type_checkers = type_checkers.remove(each) except KeyError: raise UndefinedTypeCheck(each) - return attr.evolve(self, type_checkers=type_checkers) + return evolve(self, type_checkers=type_checkers) draft3_type_checker = TypeChecker( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/jsonschema/cli.py new/jsonschema-4.18.3/jsonschema/cli.py --- old/jsonschema-4.18.0/jsonschema/cli.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/jsonschema/cli.py 2020-02-02 01:00:00.000000000 +0100 @@ -16,7 +16,7 @@ except ImportError: from pkgutil_resolve_name import resolve_name # type: ignore -import attr +from attrs import define, field from jsonschema.exceptions import SchemaError from jsonschema.validators import _RefResolver, validator_for @@ -36,12 +36,12 @@ pass -@attr.s +@define class _Outputter: - _formatter = attr.ib() - _stdout = attr.ib() - _stderr = attr.ib() + _formatter = field() + _stdout = field() + _stderr = field() @classmethod def from_arguments(cls, arguments, stdout, stderr): @@ -78,7 +78,7 @@ self._stdout.write(self._formatter.validation_success(**kwargs)) -@attr.s +@define class _PrettyFormatter: _ERROR_MSG = dedent( @@ -120,10 +120,10 @@ return self._SUCCESS_MSG.format(path=instance_path) -@attr.s +@define class _PlainFormatter: - _error_format = attr.ib() + _error_format = field() def filenotfound_error(self, path, exc_info): return "{!r} does not exist.\n".format(path) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/jsonschema/exceptions.py new/jsonschema-4.18.3/jsonschema/exceptions.py --- old/jsonschema-4.18.0/jsonschema/exceptions.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/jsonschema/exceptions.py 2020-02-02 01:00:00.000000000 +0100 @@ -11,8 +11,8 @@ import itertools import warnings +from attrs import define from referencing.exceptions import Unresolvable as _Unresolvable -import attr from jsonschema import _utils @@ -193,7 +193,7 @@ _word_for_instance_in_error_message = "schema" -@attr.s(hash=True) +@define(slots=False) class _RefResolutionError(Exception): """ A ref could not be resolved. @@ -205,7 +205,12 @@ "directly catch referencing.exceptions.Unresolvable." ) - _cause = attr.ib() + _cause: Exception + + def __eq__(self, other): + if self.__class__ is not other.__class__: + return NotImplemented + return self._cause == other._cause def __str__(self): return str(self._cause) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/jsonschema/tests/test_validators.py new/jsonschema-4.18.3/jsonschema/tests/test_validators.py --- old/jsonschema-4.18.0/jsonschema/tests/test_validators.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/jsonschema/tests/test_validators.py 2020-02-02 01:00:00.000000000 +0100 @@ -4,6 +4,7 @@ from contextlib import contextmanager from decimal import Decimal from io import BytesIO +from typing import Any from unittest import TestCase, mock from urllib.request import pathname2url import json @@ -12,8 +13,8 @@ import tempfile import warnings +from attrs import define, field from referencing.jsonschema import DRAFT202012 -import attr import referencing.exceptions from jsonschema import ( @@ -284,6 +285,23 @@ Derived = validators.extend(Original) self.assertEqual(Derived.ID_OF(Derived.META_SCHEMA), correct_id) + def test_extend_applicable_validators(self): + """ + Extending a validator preserves its notion of applicable validators. + """ + + schema = { + "$defs": {"test": {"type": "number"}}, + "$ref": "#/$defs/test", + "maximum": 1 + } + + draft4 = validators.Draft4Validator(schema) + self.assertTrue(draft4.is_valid(37)) # as $ref ignores siblings + + Derived = validators.extend(validators.Draft4Validator) + self.assertTrue(Derived(schema).is_valid(37)) + class TestValidationErrorMessages(TestCase): def message_for(self, instance, schema, *args, **kwargs): @@ -1570,10 +1588,10 @@ """ with self.assertWarns(DeprecationWarning): - @attr.s + @define class OhNo(self.Validator): - foo = attr.ib(factory=lambda: [1, 2, 3]) - _bar = attr.ib(default=37) + foo = field(factory=lambda: [1, 2, 3]) + _bar = field(default=37) validator = OhNo({}, bar=12) self.assertEqual(validator.foo, [1, 2, 3]) @@ -2372,6 +2390,47 @@ validator = validators.Draft7Validator(another, resolver=two) self.assertFalse(validator.is_valid({"maxLength": "foo"})) + def test_newly_created_validator_with_ref_resolver(self): + """ + See https://github.com/python-jsonschema/jsonschema/issues/1061#issuecomment-1624266555. + """ # noqa: E501 + + def handle(uri): + self.assertEqual(uri, "http://example.com/foo") + return {"type": "integer"} + + resolver = validators._RefResolver("", {}, handlers={"http": handle}) + Validator = validators.create( + meta_schema={}, + validators=validators.Draft4Validator.VALIDATORS, + ) + schema = {"$id": "http://example.com/bar", "$ref": "foo"} + validator = Validator(schema, resolver=resolver) + self.assertEqual( + (validator.is_valid({}), validator.is_valid(37)), + (False, True), + ) + + def test_refresolver_with_pointer_in_schema_with_no_id(self): + """ + See https://github.com/python-jsonschema/jsonschema/issues/1124#issuecomment-1632574249. + """ # noqa: E501 + + schema = { + "properties": {"x": {"$ref": "#/definitions/x"}}, + "definitions": {"x": {"type": "integer"}}, + } + + validator = validators.Draft202012Validator( + schema, + resolver=validators._RefResolver("", schema), + ) + self.assertEqual( + (validator.is_valid({"x": "y"}), validator.is_valid({"x": 37})), + (False, True), + ) + + def sorted_errors(errors): def key(error): @@ -2382,10 +2441,10 @@ return sorted(errors, key=key) -@attr.s +@define class ReallyFakeRequests: - _responses = attr.ib() + _responses: dict[str, Any] def get(self, url): response = self._responses.get(url) @@ -2394,10 +2453,10 @@ return _ReallyFakeJSONResponse(json.dumps(response)) -@attr.s +@define class _ReallyFakeJSONResponse: - _response = attr.ib() + _response: str def json(self): return json.loads(self._response) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/jsonschema/validators.py new/jsonschema-4.18.3/jsonschema/validators.py --- old/jsonschema-4.18.0/jsonschema/validators.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/jsonschema/validators.py 2020-02-02 01:00:00.000000000 +0100 @@ -219,6 +219,8 @@ FORMAT_CHECKER = format_checker_arg ID_OF = staticmethod(id_of) + _APPLICABLE_VALIDATORS = applicable_validators + schema: referencing.jsonschema.Schema = field(repr=reprlib.repr) _ref_resolver = field(default=None, repr=False, alias="resolver") format_checker: _format.FormatChecker | None = field(default=None) @@ -275,6 +277,13 @@ resource = specification.create_resource(self.schema) self._resolver = registry.resolver_with_root(resource) + # REMOVEME: Legacy ref resolution state management. + push_scope = getattr(self._ref_resolver, "push_scope", None) + if push_scope is not None: + id = id_of(self.schema) + if id is not None: + push_scope(id) + @classmethod def check_schema(cls, schema, format_checker=_UNSET): Validator = validator_for(cls.META_SCHEMA, default=cls) @@ -563,6 +572,7 @@ type_checker=type_checker, format_checker=format_checker, id_of=validator.ID_OF, + applicable_validators=validator._APPLICABLE_VALIDATORS, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.18.0/noxfile.py new/jsonschema-4.18.3/noxfile.py --- old/jsonschema-4.18.0/noxfile.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.18.3/noxfile.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,4 +1,5 @@ from pathlib import Path +from tempfile import TemporaryDirectory import os import nox @@ -106,18 +107,13 @@ @session(tags=["build"]) def build(session): - session.install("build") - tmpdir = session.create_tmp() - session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) - - -@session(tags=["style"]) -def readme(session): session.install("build", "docutils", "twine") - tmpdir = session.create_tmp() - session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) - session.run("python", "-m", "twine", "check", "--strict", tmpdir + "/*") - session.run("rst2html5.py", "--halt=warning", CHANGELOG, "/dev/null") + with TemporaryDirectory() as tmpdir: + session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) + session.run("twine", "check", "--strict", tmpdir + "/*") + session.run( + "python", "-m", "docutils", "--strict", CHANGELOG, os.devnull, + ) @session() @@ -154,20 +150,21 @@ ) def docs(session, builder): session.install("-r", DOCS / "requirements.txt") - tmpdir = Path(session.create_tmp()) - argv = ["-n", "-T", "-W"] - if builder != "spelling": - argv += ["-q"] - session.run( - "python", - "-m", - "sphinx", - "-b", - builder, - DOCS, - tmpdir / builder, - *argv, - ) + with TemporaryDirectory() as tmpdir_str: + tmpdir = Path(tmpdir_str) + argv = ["-n", "-T", "-W"] + if builder != "spelling": + argv += ["-q"] + session.run( + "python", + "-m", + "sphinx", + "-b", + builder, + DOCS, + tmpdir / builder, + *argv, + ) @session(tags=["docs", "style"], name="docs(style)")