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 2022-11-17 17:23:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jsonschema (Old) and /work/SRC/openSUSE:Factory/.python-jsonschema.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jsonschema" Thu Nov 17 17:23:41 2022 rev:33 rq:1035979 version:4.17.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-jsonschema/python-jsonschema.changes 2022-10-14 15:40:33.163719364 +0200 +++ /work/SRC/openSUSE:Factory/.python-jsonschema.new.1597/python-jsonschema.changes 2022-11-17 17:23:48.708845576 +0100 @@ -1,0 +2,8 @@ +Tue Nov 15 09:56:17 UTC 2022 - Johannes Kastl <ka...@b1-systems.de> + +- update to 4.17.0: + * The check_schema method on jsonschema.protocols.Validator instances now enables format validation by default when run. This can catch some additional invalid schemas (e.g. containing invalid regular expressions) where the issue is indeed uncovered by validating against the metaschema with format validation enabled as an assertion. + * The jsonschema CLI (along with jsonschema.cli the module) are now deprecated. Use check-jsonschema instead, which can be installed via pip install check-jsonschema and found here. + * Make ErrorTree have a more grammatically correct repr. + +------------------------------------------------------------------- Old: ---- jsonschema-4.16.0.tar.gz New: ---- jsonschema-4.17.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jsonschema.spec ++++++ --- /var/tmp/diff_new_pack.cjARmB/_old 2022-11-17 17:23:49.548850017 +0100 +++ /var/tmp/diff_new_pack.cjARmB/_new 2022-11-17 17:23:49.552850039 +0100 @@ -23,7 +23,7 @@ %endif Name: python-jsonschema -Version: 4.16.0 +Version: 4.17.0 Release: 0 Summary: An implementation of JSON-Schema validation for Python License: MIT ++++++ jsonschema-4.16.0.tar.gz -> jsonschema-4.17.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/CHANGELOG.rst new/jsonschema-4.17.0/CHANGELOG.rst --- old/jsonschema-4.16.0/CHANGELOG.rst 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/CHANGELOG.rst 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,21 @@ +v4.17.0 +======= + +* The ``check_schema`` method on ``jsonschema.protocols.Validator`` instances + now *enables* format validation by default when run. This can catch some + additional invalid schemas (e.g. containing invalid regular expressions) + where the issue is indeed uncovered by validating against the metaschema + with format validation enabled as an assertion. +* The ``jsonschema`` CLI (along with ``jsonschema.cli`` the module) are now + deprecated. Use ``check-jsonschema`` instead, which can be installed via + ``pip install check-jsonschema`` and found + `here <https://github.com/python-jsonschema/check-jsonschema>`_. + +v4.16.1 +======= + +* Make ``ErrorTree`` have a more grammatically correct ``repr``. + v4.16.0 ======= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/PKG-INFO new/jsonschema-4.17.0/PKG-INFO --- old/jsonschema-4.16.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: jsonschema -Version: 4.16.0 +Version: 4.17.0 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/ @@ -12,6 +12,7 @@ Author: Julian Berman Author-email: julian+jsonsch...@grayvines.com License: MIT +License-File: COPYING Keywords: data validation,json,jsonschema,validation Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers @@ -159,6 +160,9 @@ $ pip install jsonschema'[format]' +Be aware that the mere presence of these dependencies â or even the specification of ``format`` checks in a schema â do *not* activate format checks (as per the specification). +Please read the `format validation documentation <https://python-jsonschema.readthedocs.io/en/latest/validate/#validating-formats>`_ for further details. + About ----- @@ -184,12 +188,15 @@ Release Information ------------------- -v4.16.0 +v4.17.0 ======= -* Improve the base URI behavior when resolving a ``$ref`` to a resolution URI - which is different from the resolved schema's declared ``$id``. -* Accessing ``jsonschema.draftN_format_checker`` is deprecated. Instead, if you - want access to the format checker itself, it is exposed as - ``jsonschema.validators.DraftNValidator.FORMAT_CHECKER`` on any - ``jsonschema.protocols.Validator``. +* The ``check_schema`` method on ``jsonschema.protocols.Validator`` instances + now *enables* format validation by default when run. This can catch some + additional invalid schemas (e.g. containing invalid regular expressions) + where the issue is indeed uncovered by validating against the metaschema + with format validation enabled as an assertion. +* The ``jsonschema`` CLI (along with ``jsonschema.cli`` the module) are now + deprecated. Use ``check-jsonschema`` instead, which can be installed via + ``pip install check-jsonschema`` and found + `here <https://github.com/python-jsonschema/check-jsonschema>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/README.rst new/jsonschema-4.17.0/README.rst --- old/jsonschema-4.16.0/README.rst 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/README.rst 2020-02-02 01:00:00.000000000 +0100 @@ -105,6 +105,9 @@ $ pip install jsonschema'[format]' +Be aware that the mere presence of these dependencies â or even the specification of ``format`` checks in a schema â do *not* activate format checks (as per the specification). +Please read the `format validation documentation <https://python-jsonschema.readthedocs.io/en/latest/validate/#validating-formats>`_ for further details. + .. start cut from PyPI Running the Test Suite diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/docs/validate.rst new/jsonschema-4.17.0/docs/validate.rst --- old/jsonschema-4.16.0/docs/validate.rst 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/docs/validate.rst 2020-02-02 01:00:00.000000000 +0100 @@ -24,7 +24,7 @@ .. _validator-protocol: The Validator Protocol ------------------------ +---------------------- `jsonschema` defines a `protocol <typing.Protocol>` that all validator classes adhere to. @@ -173,7 +173,8 @@ ------------------ JSON Schema defines the :kw:`format` keyword which can be used to check if primitive types (``string``\s, ``number``\s, ``boolean``\s) conform to well-defined formats. -By default, no validation is enforced, but optionally, validation can be enabled by hooking in a format-checking object into a `Validator`. +By default, as per the specification, no validation is enforced. +Optionally however, validation can be enabled by hooking a `format-checking object <jsonschema.FormatChecker>` into a `Validator`. .. doctest:: @@ -187,70 +188,31 @@ ... ValidationError: "-12" is not a "ipv4" -.. autoclass:: FormatChecker - :members: - :exclude-members: cls_checks - - .. attribute:: checkers - - A mapping of currently known formats to tuple of functions that validate them and errors that should be caught. - New checkers can be added and removed either per-instance or globally for all checkers using the `FormatChecker.checks` decorator. - - .. classmethod:: cls_checks(format, raises=()) - - Register a decorated function as *globally* validating a new format. - - Any instance created after this function is called will pick up the supplied checker. - - :argument str format: the format that the decorated function will check - :argument Exception raises: the exception(s) raised - by the decorated function when an invalid instance is - found. The exception object will be accessible as the - `jsonschema.exceptions.ValidationError.cause` attribute - of the resulting validation error. - .. deprecated:: v4.14.0 +Some formats require additional dependencies to be installed. - Use `FormatChecker.checks` on an instance instead. +The easiest way to ensure you have what is needed is to install ``jsonschema`` using the ``format`` or ``format-nongpl`` extras. - -.. autoexception:: FormatError - :noindex: - :members: - - -There are a number of default checkers that `FormatChecker`\s know how -to validate. Their names can be viewed by inspecting the -`FormatChecker.checkers` attribute. Certain checkers will only be -available if an appropriate package is available for use. The easiest way to -ensure you have what is needed is to install ``jsonschema`` using the -``format`` or ``format_nongpl`` collection of optional dependencies -- e.g. +For example: .. code-block:: sh - $ pip install jsonschema[format] - -which will install all of the below dependencies for all formats. + $ pip install jsonschema[format] Or if you want to install MIT-license compatible dependencies only: .. code-block:: sh - $ pip install jsonschema[format_nongpl] + $ pip install jsonschema[format-nongpl] -The non-GPL extra is intended to not install any direct dependencies -that are GPL (but that of course end-users should do their own verification). -At the moment, it supports all the available checkers except for ``iri`` and -``iri-reference``. +The non-GPL extra is intended to not install any direct dependencies that are GPL licensed (but that of course end-users should do their own verification). +At the moment, it supports all the available checkers except for ``iri`` and ``iri-reference``. -The more specific list of available checkers, along with their requirement -(if any,) are listed below. +The more specific list of formats along with any additional dependencies they have is shown below. -.. note:: +.. warning:: - If the following packages are not installed when using a checker - that requires it, validation will succeed without throwing an error, - as specified by the JSON Schema specification. + If a dependency is not installed when using a checker that requires it, validation will succeed without throwing an error, as also specified by the specification. ========================= ==================== Checker Notes @@ -283,18 +245,57 @@ .. _rfc3339-validator: https://pypi.org/project/rfc3339-validator/ .. _rfc3986-validator: https://pypi.org/project/rfc3986-validator/ .. _rfc3987: https://pypi.org/pypi/rfc3987/ -.. _rfc5322: https://tools.ietf.org/html/rfc5322#section-3.4.1 .. _uri-template: https://pypi.org/pypi/uri-template/ .. _webcolors: https://pypi.org/pypi/webcolors/ -.. note:: +The supported mechanism for ensuring these dependencies are present is again as shown above, not by directly installing the packages. + +.. autoclass:: FormatChecker + :members: + :exclude-members: cls_checks + + .. attribute:: checkers + + A mapping of currently known formats to tuple of functions that validate them and errors that should be caught. + New checkers can be added and removed either per-instance or globally for all checkers using the `FormatChecker.checks` decorator. + + .. classmethod:: cls_checks(format, raises=()) + + Register a decorated function as *globally* validating a new format. + + Any instance created after this function is called will pick up the supplied checker. + + :argument str format: the format that the decorated function will check + :argument Exception raises: the exception(s) raised + by the decorated function when an invalid instance is + found. The exception object will be accessible as the + `jsonschema.exceptions.ValidationError.cause` attribute + of the resulting validation error. + + .. deprecated:: v4.14.0 + + Use `FormatChecker.checks` on an instance instead. + +.. autoexception:: FormatError + :noindex: + :members: + + +Format-Specific Notes +~~~~~~~~~~~~~~~~~~~~~ + +regex +^^^^^ + +The JSON Schema specification `recommends (but does not require) <https://json-schema.org/draft/2020-12/json-schema-core.html#name-regular-expressions>`_ that implementations use ECMA 262 regular expressions. + +Given that there is no current library in Python capable of supporting the ECMA 262 dialect, the ``regex`` format will instead validate *Python* regular expressions, which are the ones used by this implementation for other keywords like :kw:`pattern` or :kw:`patternProperties`. + +email +^^^^^ + +Since in most cases "validating" an email address is an attempt instead to confirm that mail sent to it will deliver to a recipient, and that that recipient is the correct one the email is intended for, and since many valid email addresses are in many places incorrectly rejected, and many invalid email addresses are in many places incorrectly accepted, the ``email`` format keyword only provides a sanity check, not full :RFC:`5322` validation. - Since in most cases "validating" an email address is an attempt - instead to confirm that mail sent to it will deliver to a recipient, - and that that recipient is the correct one the email is intended - for, and since many valid email addresses are in many places - incorrectly rejected, and many invalid email addresses are in many - places incorrectly accepted, the ``email`` format keyword only - provides a sanity check, not full rfc5322_ validation. +The same applies to the ``idn-email`` format. - The same applies to the ``idn-email`` format. +If you indeed want a particular well-specified set of emails to be considered valid, you can use `FormatChecker.checks` to provide your specific definition. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/cli.py new/jsonschema-4.17.0/jsonschema/cli.py --- old/jsonschema-4.16.0/jsonschema/cli.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/cli.py 2020-02-02 01:00:00.000000000 +0100 @@ -8,6 +8,7 @@ import json import sys import traceback +import warnings try: from importlib import metadata @@ -24,6 +25,16 @@ from jsonschema.exceptions import SchemaError from jsonschema.validators import RefResolver, validator_for +warnings.warn( + ( + "The jsonschema CLI is deprecated and will be removed in a future " + "version. Please use check-jsonschema instead, which can be installed " + "from https://pypi.org/project/check-jsonschema/" + ), + DeprecationWarning, + stacklevel=2, +) + class _CannotLoadFile(Exception): pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/exceptions.py new/jsonschema-4.17.0/jsonschema/exceptions.py --- old/jsonschema-4.16.0/jsonschema/exceptions.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/exceptions.py 2020-02-02 01:00:00.000000000 +0100 @@ -297,7 +297,9 @@ return self.total_errors def __repr__(self): - return f"<{self.__class__.__name__} ({len(self)} total errors)>" + total = len(self) + errors = "error" if total == 1 else "errors" + return f"<{self.__class__.__name__} ({total} total {errors})>" @property def total_errors(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/schemas/draft3.json new/jsonschema-4.17.0/jsonschema/schemas/draft3.json --- old/jsonschema-4.16.0/jsonschema/schemas/draft3.json 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/schemas/draft3.json 2020-02-02 01:00:00.000000000 +0100 @@ -15,7 +15,7 @@ "properties" : { "type" : "object", - "additionalProperties" : {"$ref" : "#", "type" : "object"}, + "additionalProperties" : {"$ref" : "#"}, "default" : {} }, @@ -47,7 +47,7 @@ }, "dependencies" : { - "type" : ["string", "array", "object"], + "type" : "object", "additionalProperties" : { "type" : ["string", "array", {"$ref" : "#"}], "items" : { @@ -75,11 +75,6 @@ "default" : false }, - "maxDecimal": { - "minimum": 0, - "type": "number" - }, - "minItems" : { "type" : "integer", "minimum" : 0, @@ -112,7 +107,9 @@ }, "enum" : { - "type" : "array" + "type" : "array", + "minItems" : 1, + "uniqueItems" : true }, "default" : { @@ -153,13 +150,11 @@ }, "id" : { - "type" : "string", - "format" : "uri" + "type" : "string" }, "$ref" : { - "type" : "string", - "format" : "uri" + "type" : "string" }, "$schema" : { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/schemas/draft4.json new/jsonschema-4.17.0/jsonschema/schemas/draft4.json --- old/jsonschema-4.16.0/jsonschema/schemas/draft4.json 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/schemas/draft4.json 2020-02-02 01:00:00.000000000 +0100 @@ -28,12 +28,10 @@ "type": "object", "properties": { "id": { - "format": "uri", "type": "string" }, "$schema": { - "type": "string", - "format": "uri" + "type": "string" }, "title": { "type": "string" @@ -122,7 +120,9 @@ } }, "enum": { - "type": "array" + "type": "array", + "minItems": 1, + "uniqueItems": true }, "type": { "anyOf": [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/tests/test_cli.py new/jsonschema-4.17.0/jsonschema/tests/test_cli.py --- old/jsonschema-4.16.0/jsonschema/tests/test_cli.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/tests/test_cli.py 2020-02-02 01:00:00.000000000 +0100 @@ -9,6 +9,7 @@ import subprocess import sys import tempfile +import warnings try: # pragma: no cover from importlib import metadata @@ -17,7 +18,7 @@ from pyrsistent import m -from jsonschema import Draft4Validator, Draft202012Validator, cli +from jsonschema import Draft4Validator, Draft202012Validator from jsonschema.exceptions import ( RefResolutionError, SchemaError, @@ -25,6 +26,10 @@ ) from jsonschema.validators import _LATEST_VERSION, validate +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + from jsonschema import cli + def fake_validator(*errors): errors = list(reversed(errors)) @@ -895,7 +900,7 @@ def test_version(self): version = subprocess.check_output( - [sys.executable, "-m", "jsonschema", "--version"], + [sys.executable, "-W", "ignore", "-m", "jsonschema", "--version"], stderr=subprocess.STDOUT, ) version = version.decode("utf-8").strip() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/tests/test_deprecations.py new/jsonschema-4.17.0/jsonschema/tests/test_deprecations.py --- old/jsonschema-4.16.0/jsonschema/tests/test_deprecations.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/tests/test_deprecations.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,4 +1,6 @@ from unittest import TestCase +import subprocess +import sys from jsonschema import FormatChecker, validators @@ -261,3 +263,14 @@ with self.assertRaises(ImportError): from jsonschema import draft1234_format_checker # noqa + + def test_cli(self): + """ + As of v4.17.0, the jsonschema CLI is deprecated. + """ + + process = subprocess.run( + [sys.executable, "-m", "jsonschema"], + capture_output=True, + ) + self.assertIn(b"The jsonschema CLI is deprecated ", process.stderr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/tests/test_exceptions.py new/jsonschema-4.17.0/jsonschema/tests/test_exceptions.py --- old/jsonschema-4.16.0/jsonschema/tests/test_exceptions.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/tests/test_exceptions.py 2020-02-02 01:00:00.000000000 +0100 @@ -396,7 +396,17 @@ tree = exceptions.ErrorTree([error]) self.assertIsInstance(tree["foo"], exceptions.ErrorTree) - def test_repr(self): + def test_repr_single(self): + error = exceptions.ValidationError( + "1", + validator="foo", + path=["bar", "bar2"], + instance="i1", + ) + tree = exceptions.ErrorTree([error]) + self.assertEqual(repr(tree), "<ErrorTree (1 total error)>") + + def test_repr_multiple(self): e1, e2 = ( exceptions.ValidationError( "1", @@ -412,6 +422,10 @@ tree = exceptions.ErrorTree([e1, e2]) self.assertEqual(repr(tree), "<ErrorTree (2 total errors)>") + def test_repr_empty(self): + tree = exceptions.ErrorTree([]) + self.assertEqual(repr(tree), "<ErrorTree (0 total errors)>") + class TestErrorInitReprStr(TestCase): def make_error(self, **kwargs): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/tests/test_validators.py new/jsonschema-4.17.0/jsonschema/tests/test_validators.py --- old/jsonschema-4.16.0/jsonschema/tests/test_validators.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/tests/test_validators.py 2020-02-02 01:00:00.000000000 +0100 @@ -1453,17 +1453,45 @@ """ Technically, all the spec says is they SHOULD have elements, not MUST. + (As of Draft 6. Previous drafts do say MUST). + See #529. """ - self.Validator.check_schema({"enum": []}) + if self.Validator in { + validators.Draft3Validator, + validators.Draft4Validator, + }: + with self.assertRaises(exceptions.SchemaError): + self.Validator.check_schema({"enum": []}) + else: + self.Validator.check_schema({"enum": []}) def test_enum_allows_non_unique_items(self): """ Technically, all the spec says is they SHOULD be unique, not MUST. + (As of Draft 6. Previous drafts do say MUST). + See #529. """ - self.Validator.check_schema({"enum": [12, 12]}) + if self.Validator in { + validators.Draft3Validator, + validators.Draft4Validator, + }: + with self.assertRaises(exceptions.SchemaError): + self.Validator.check_schema({"enum": [12, 12]}) + else: + self.Validator.check_schema({"enum": [12, 12]}) + + def test_schema_with_invalid_regex(self): + with self.assertRaises(exceptions.SchemaError): + self.Validator.check_schema({"pattern": "*notaregex"}) + + def test_schema_with_invalid_regex_with_disabled_format_validation(self): + self.Validator.check_schema( + {"pattern": "*notaregex"}, + format_checker=None, + ) class ValidatorTestMixin(MetaSchemaTestsMixin, object): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonschema-4.16.0/jsonschema/validators.py new/jsonschema-4.17.0/jsonschema/validators.py --- old/jsonschema-4.16.0/jsonschema/validators.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jsonschema-4.17.0/jsonschema/validators.py 2020-02-02 01:00:00.000000000 +0100 @@ -215,9 +215,15 @@ ) @classmethod - def check_schema(cls, schema): + def check_schema(cls, schema, format_checker=_UNSET): Validator = validator_for(cls.META_SCHEMA, default=cls) - for error in Validator(cls.META_SCHEMA).iter_errors(schema): + if format_checker is _UNSET: + format_checker = Validator.FORMAT_CHECKER + validator = Validator( + schema=cls.META_SCHEMA, + format_checker=format_checker, + ) + for error in validator.iter_errors(schema): raise exceptions.SchemaError.create_from(error) def evolve(self, **changes): @@ -758,7 +764,7 @@ `RefResolver` """ - return cls(base_uri=id_of(schema), referrer=schema, *args, **kwargs) + return cls(base_uri=id_of(schema), referrer=schema, *args, **kwargs) # noqa: B026, E501 def push_scope(self, scope): """