🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

jsonschema

Package Overview
Dependencies
Maintainers
0
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonschema - pypi Package Compare versions

Comparing version
4.23.0
to
4.24.0
+2
jsonschema-4.24.0.dist-info/entry_points.txt
[console_scripts]
jsonschema = jsonschema.cli:main
Copyright (c) 2013 Julian Berman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Metadata-Version: 2.4
Name: jsonschema
Version: 4.24.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/
Project-URL: Issues, https://github.com/python-jsonschema/jsonschema/issues/
Project-URL: Funding, https://github.com/sponsors/Julian
Project-URL: Tidelift, https://tidelift.com/subscription/pkg/pypi-jsonschema?utm_source=pypi-jsonschema&utm_medium=referral&utm_campaign=pypi-link
Project-URL: Changelog, https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst
Project-URL: Source, https://github.com/python-jsonschema/jsonschema
Author-email: Julian Berman <Julian+jsonschema@GrayVines.com>
License-Expression: MIT
License-File: COPYING
Keywords: data validation,json,json schema,jsonschema,validation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: File Formats :: JSON
Classifier: Topic :: File Formats :: JSON :: JSON Schema
Requires-Python: >=3.9
Requires-Dist: attrs>=22.2.0
Requires-Dist: importlib-resources>=1.4.0; python_version < '3.9'
Requires-Dist: jsonschema-specifications>=2023.03.6
Requires-Dist: pkgutil-resolve-name>=1.3.10; python_version < '3.9'
Requires-Dist: referencing>=0.28.4
Requires-Dist: rpds-py>=0.7.1
Provides-Extra: format
Requires-Dist: fqdn; extra == 'format'
Requires-Dist: idna; extra == 'format'
Requires-Dist: isoduration; extra == 'format'
Requires-Dist: jsonpointer>1.13; extra == 'format'
Requires-Dist: rfc3339-validator; extra == 'format'
Requires-Dist: rfc3987; extra == 'format'
Requires-Dist: uri-template; extra == 'format'
Requires-Dist: webcolors>=1.11; extra == 'format'
Provides-Extra: format-nongpl
Requires-Dist: fqdn; extra == 'format-nongpl'
Requires-Dist: idna; extra == 'format-nongpl'
Requires-Dist: isoduration; extra == 'format-nongpl'
Requires-Dist: jsonpointer>1.13; extra == 'format-nongpl'
Requires-Dist: rfc3339-validator; extra == 'format-nongpl'
Requires-Dist: rfc3986-validator>0.1.0; extra == 'format-nongpl'
Requires-Dist: uri-template; extra == 'format-nongpl'
Requires-Dist: webcolors>=24.6.0; extra == 'format-nongpl'
Description-Content-Type: text/x-rst
==========
jsonschema
==========
|PyPI| |Pythons| |CI| |ReadTheDocs| |Precommit| |Zenodo|
.. |PyPI| image:: https://img.shields.io/pypi/v/jsonschema.svg
:alt: PyPI version
:target: https://pypi.org/project/jsonschema/
.. |Pythons| image:: https://img.shields.io/pypi/pyversions/jsonschema.svg
:alt: Supported Python versions
:target: https://pypi.org/project/jsonschema/
.. |CI| image:: https://github.com/python-jsonschema/jsonschema/workflows/CI/badge.svg
:alt: Build status
:target: https://github.com/python-jsonschema/jsonschema/actions?query=workflow%3ACI
.. |ReadTheDocs| image:: https://readthedocs.org/projects/python-jsonschema/badge/?version=stable&style=flat
:alt: ReadTheDocs status
:target: https://python-jsonschema.readthedocs.io/en/stable/
.. |Precommit| image:: https://results.pre-commit.ci/badge/github/python-jsonschema/jsonschema/main.svg
:alt: pre-commit.ci status
:target: https://results.pre-commit.ci/latest/github/python-jsonschema/jsonschema/main
.. |Zenodo| image:: https://zenodo.org/badge/3072629.svg
:alt: Zenodo DOI
:target: https://zenodo.org/badge/latestdoi/3072629
``jsonschema`` is an implementation of the `JSON Schema <https://json-schema.org>`_ specification for Python.
.. code:: python
>>> from jsonschema import validate
>>> # A sample schema, like what we'd get from json.load()
>>> schema = {
... "type" : "object",
... "properties" : {
... "price" : {"type" : "number"},
... "name" : {"type" : "string"},
... },
... }
>>> # If no exception is raised by validate(), the instance is valid.
>>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema)
>>> validate(
... instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema,
... ) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValidationError: 'Invalid' is not of type 'number'
It can also be used from the command line by installing `check-jsonschema <https://github.com/python-jsonschema/check-jsonschema>`_.
Features
--------
* Full support for `Draft 2020-12 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft202012Validator>`_, `Draft 2019-09 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft201909Validator>`_, `Draft 7 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft7Validator>`_, `Draft 6 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft6Validator>`_, `Draft 4 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft4Validator>`_ and `Draft 3 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft3Validator>`_
* `Lazy validation <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/protocols/#jsonschema.protocols.Validator.iter_errors>`_ that can iteratively report *all* validation errors.
* `Programmatic querying <https://python-jsonschema.readthedocs.io/en/latest/errors/>`_ of which properties or items failed validation.
Installation
------------
``jsonschema`` is available on `PyPI <https://pypi.org/project/jsonschema/>`_. You can install using `pip <https://pip.pypa.io/en/stable/>`_:
.. code:: bash
$ pip install jsonschema
Extras
======
Two extras are available when installing the package, both currently related to ``format`` validation:
* ``format``
* ``format-nongpl``
They can be used when installing in order to include additional dependencies, e.g.:
.. code:: bash
$ 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
-----
I'm Julian Berman.
``jsonschema`` is on `GitHub <https://github.com/python-jsonschema/jsonschema>`_.
Get in touch, via GitHub or otherwise, if you've got something to contribute, it'd be most welcome!
If you feel overwhelmingly grateful, you can also `sponsor me <https://github.com/sponsors/Julian/>`_.
And for companies who appreciate ``jsonschema`` and its continued support and growth, ``jsonschema`` is also now supportable via `TideLift <https://tidelift.com/subscription/pkg/pypi-jsonschema?utm_source=pypi-jsonschema&utm_medium=referral&utm_campaign=readme>`_.
Release Information
-------------------
v4.24.0
=======
* Fix improper handling of ``unevaluatedProperties`` in the presence of ``additionalProperties`` (#1351).
* Support for Python 3.8 has been dropped, as it is end-of-life.
jsonschema/__init__.py,sha256=p-Rw4TS_0OPHZIJyImDWsdWgmd6CPWHMXLq7BuQxTGc,3941
jsonschema/__main__.py,sha256=iLsZf2upUB3ilBKTlMnyK-HHt2Cnnfkwwxi_c6gLvSA,115
jsonschema/_format.py,sha256=XMG7Qu44gUEH1H6h-gvU2BKZR0EfzqVfAtjoI9BasbM,14747
jsonschema/_keywords.py,sha256=r8_DrqAfn6QLwQnmXEggveiSU-UaIL2p2nuPINelfFc,14949
jsonschema/_legacy_keywords.py,sha256=2tWuwRPWbYS7EAl8wBIC_rabGuv1J4dfYLqNEPpShhA,15191
jsonschema/_types.py,sha256=0pYJG61cn_4ZWVnqyD24tax2QBMlnSPy0fcECCpASMk,5456
jsonschema/_typing.py,sha256=hFfAEeFJ76LYAl_feuVa0gnHnV9VEq_UhjLJS-7axgY,630
jsonschema/_utils.py,sha256=Xv6_wKKslBJlwyj9-j2c8JDFw-4z4aWFnVe2pX8h7U4,10659
jsonschema/cli.py,sha256=SGy9JPg02mgXhNxugU8iXhYNivfSjBhKTNAgV90ty-M,8551
jsonschema/exceptions.py,sha256=l1wGgRg_8lpS1r8g9WpUC1Sue9DmMHc3chk6GLXYLzg,14951
jsonschema/protocols.py,sha256=Cv3L2xUl1MxQCRMcpNNbBL0nh14ekPYoazNfochqiag,7145
jsonschema/validators.py,sha256=8gThVddl0AObBsfChZ2rrzyRUosnFdICxzIL8xrvu84,47098
jsonschema/benchmarks/__init__.py,sha256=A0sQrxDBVHSyQ-8ru3L11hMXf3q9gVuB9x_YgHb4R9M,70
jsonschema/benchmarks/const_vs_enum.py,sha256=DVFi3WDqBalZFOibnjpX1uTSr3Rxa2cPgFcowd7Ukrs,830
jsonschema/benchmarks/contains.py,sha256=gexQoUrCOwECofbt19BeosQZ7WFL6PDdkX49DWwBlOg,786
jsonschema/benchmarks/issue232.py,sha256=3LLYLIlBGQnVuyyo2iAv-xky5P6PRFHANx4-zIIQOoE,521
jsonschema/benchmarks/json_schema_test_suite.py,sha256=PvfabpUYcF4_7csYDTcTauED8rnFEGYbdY5RqTXD08s,320
jsonschema/benchmarks/nested_schemas.py,sha256=mo07dx-CIgmSOI62CNs4g5xu1FzHklLBpkQoDxWYcKs,1892
jsonschema/benchmarks/subcomponents.py,sha256=fEyiMzsWeK2pd7DEGCuuY-vzGunwhHczRBWEnBRLKIo,1113
jsonschema/benchmarks/unused_registry.py,sha256=hwRwONc9cefPtYzkoX_TYRO3GyUojriv0-YQaK3vnj0,940
jsonschema/benchmarks/useless_applicator_schemas.py,sha256=EVm5-EtOEFoLP_Vt2j4SrCwlx05NhPqNuZQ6LIMP1Dc,3342
jsonschema/benchmarks/useless_keywords.py,sha256=bj_zKr1oVctFlqyZaObCsYTgFjiiNgPzC0hr1Y868mE,867
jsonschema/benchmarks/validator_creation.py,sha256=UkUQlLAnussnr_KdCIdad6xx2pXxQLmYtsXoiirKeWQ,285
jsonschema/benchmarks/issue232/issue.json,sha256=eaPOZjMRu5u8RpKrsA9uk7ucPZS5tkKG4D_hkOTQ3Hk,117105
jsonschema/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
jsonschema/tests/_suite.py,sha256=2k0X91N7dOHhQc5mrYv40OKf1weioj6RMBqWgLT6-PI,8374
jsonschema/tests/fuzz_validate.py,sha256=fUA7yTJIihaCwJplkUehZeyB84HcXEcqtY5oPJXIO7I,1114
jsonschema/tests/test_cli.py,sha256=A89r5LOHy-peLPZA5YDkOaMTWqzQO_w2Tu8WFz_vphM,28544
jsonschema/tests/test_deprecations.py,sha256=yG6mkRJHpTHbWoxpLC5y5H7fk8erGOs8f_9V4tCBEh8,15754
jsonschema/tests/test_exceptions.py,sha256=JgC-E1ZFZK2puVBp35WFRnG8CNOiSWLYtyLjh9IvFKI,22591
jsonschema/tests/test_format.py,sha256=eVm5SMaWF2lOPO28bPAwNvkiQvHCQKy-MnuAgEchfEc,3188
jsonschema/tests/test_jsonschema_test_suite.py,sha256=tAfxknM65OR9LyDPHu1pkEaombLgjRLnJ6FPiWPdxjg,8461
jsonschema/tests/test_types.py,sha256=cF51KTDmdsx06MrIc4fXKt0X9fIsVgw5uhT8CamVa8U,6977
jsonschema/tests/test_utils.py,sha256=sao74o1PyYMxBfqweokQN48CFSS6yhJk5FkCfMJ5PsI,4163
jsonschema/tests/test_validators.py,sha256=eiaigsZMzHYYsniQ1UPygaS56a1d-_7-9NC4wVXAhzs,87975
jsonschema-4.24.0.dist-info/METADATA,sha256=Ibtqh_YF6ihrEgixIpXcUNcsTQ76s_ieJ7c0-9XevuY,7755
jsonschema-4.24.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
jsonschema-4.24.0.dist-info/entry_points.txt,sha256=vO7rX4Fs_xIVJy2pnAtKgTSxfpnozAVQ0DjCmpMxnWE,51
jsonschema-4.24.0.dist-info/licenses/COPYING,sha256=T5KgFaE8TRoEC-8BiqE0MLTxvHO0Gxa7hGw0Z2bedDk,1057
jsonschema-4.24.0.dist-info/RECORD,,
Wheel-Version: 1.0
Generator: hatchling 1.27.0
Root-Is-Purelib: true
Tag: py3-none-any
+2
-2

@@ -109,4 +109,2 @@ """

__all__ = [
"Draft201909Validator",
"Draft202012Validator",
"Draft3Validator",

@@ -116,2 +114,4 @@ "Draft4Validator",

"Draft7Validator",
"Draft201909Validator",
"Draft202012Validator",
"FormatChecker",

@@ -118,0 +118,0 @@ "SchemaError",

@@ -16,5 +16,3 @@ from __future__ import annotations

_F = typing.TypeVar("_F", bound=_FormatCheckCallable)
_RaisesType = typing.Union[
typing.Type[Exception], typing.Tuple[typing.Type[Exception], ...],
]
_RaisesType = typing.Union[type[Exception], tuple[type[Exception], ...]]

@@ -278,2 +276,6 @@ _RE_DATE = re.compile(r"^\d{4}-\d{2}-\d{2}$", re.ASCII)

draft202012="hostname",
# fqdn.FQDN("") raises a ValueError due to a bug
# however, it's not clear when or if that will be fixed, so catch it
# here for now
raises=ValueError,
)

@@ -280,0 +282,0 @@ def is_host_name(instance: object) -> bool:

from __future__ import annotations
from typing import Any, Callable, Mapping
from typing import TYPE_CHECKING
import numbers

@@ -11,3 +11,7 @@

if TYPE_CHECKING:
from collections.abc import Mapping
from typing import Any, Callable
# unfortunately, the type of HashTrieMap is generic, and if used as an attrs

@@ -196,3 +200,3 @@ # converter, the generic type is presented to mypy, which then fails to match

is_integer(checker, instance)
or isinstance(instance, float) and instance.is_integer()
or (isinstance(instance, float) and instance.is_integer())
),

@@ -199,0 +203,0 @@ )

"""
Some (initially private) typing helpers for jsonschema's types.
"""
from typing import Any, Callable, Iterable, Protocol, Tuple, Union
from collections.abc import Iterable
from typing import Any, Callable, Protocol, Union

@@ -27,3 +28,3 @@ import referencing.jsonschema

[referencing.jsonschema.Schema],
Iterable[Tuple[str, Any]],
Iterable[tuple[str, Any]],
]

@@ -301,14 +301,14 @@ from collections.abc import Mapping, MutableMapping, Sequence

for keyword in [
"properties", "additionalProperties", "unevaluatedProperties",
]:
if keyword in schema:
schema_value = schema[keyword]
if validator.is_type(schema_value, "boolean") and schema_value:
evaluated_keys += instance.keys()
properties = schema.get("properties")
if validator.is_type(properties, "object"):
evaluated_keys += properties.keys() & instance.keys()
elif validator.is_type(schema_value, "object"):
for property in schema_value:
if property in instance:
evaluated_keys.append(property)
for keyword in ["additionalProperties", "unevaluatedProperties"]:
if (subschema := schema.get(keyword)) is None:
continue
evaluated_keys += (
key
for key, value in instance.items()
if is_valid(validator.descend(value, subschema))
)

@@ -330,9 +330,8 @@ if "patternProperties" in schema:

for keyword in ["allOf", "oneOf", "anyOf"]:
if keyword in schema:
for subschema in schema[keyword]:
errs = next(validator.descend(instance, subschema), None)
if errs is None:
evaluated_keys += find_evaluated_property_keys_by_schema(
validator, instance, subschema,
)
for subschema in schema.get(keyword, []):
if not is_valid(validator.descend(instance, subschema)):
continue
evaluated_keys += find_evaluated_property_keys_by_schema(
validator, instance, subschema,
)

@@ -354,1 +353,6 @@ if "if" in schema:

return evaluated_keys
def is_valid(errs_it):
"""Whether there are no errors in the given iterator."""
return next(errs_it, None) is None

@@ -11,3 +11,2 @@ """

import heapq
import itertools
import warnings

@@ -475,7 +474,5 @@

"""
errors = iter(errors)
best = next(errors, None)
best = max(errors, key=key, default=None)
if best is None:
return
best = max(itertools.chain([best], errors), key=key)

@@ -482,0 +479,0 @@ while best.context:

@@ -10,10 +10,3 @@ """

from typing import (
TYPE_CHECKING,
Any,
ClassVar,
Iterable,
Protocol,
runtime_checkable,
)
from typing import TYPE_CHECKING, Any, ClassVar, Protocol, runtime_checkable

@@ -25,3 +18,3 @@ # in order for Sphinx to resolve references accurately from type annotations,

if TYPE_CHECKING:
from collections.abc import Mapping
from collections.abc import Iterable, Mapping

@@ -28,0 +21,0 @@ import referencing.jsonschema

@@ -13,3 +13,2 @@ """

import re
import subprocess
import sys

@@ -25,2 +24,3 @@ import unittest

from referencing.jsonschema import Schema
import pyperf

@@ -31,2 +31,4 @@

MAGIC_REMOTE_URL = "http://localhost:1234"
_DELIMITERS = re.compile(r"[\W\- ]+")

@@ -57,35 +59,4 @@

_root: Path = field(factory=_find_suite)
_remotes: referencing.jsonschema.SchemaRegistry = field(init=False)
def __attrs_post_init__(self):
jsonschema_suite = self._root.joinpath("bin", "jsonschema_suite")
argv = [sys.executable, str(jsonschema_suite), "remotes"]
remotes = subprocess.check_output(argv).decode("utf-8")
resources = json.loads(remotes)
li = "http://localhost:1234/locationIndependentIdentifierPre2019.json"
li4 = "http://localhost:1234/locationIndependentIdentifierDraft4.json"
registry = Registry().with_resources(
[
(
li,
referencing.jsonschema.DRAFT7.create_resource(
contents=resources.pop(li),
),
),
(
li4,
referencing.jsonschema.DRAFT4.create_resource(
contents=resources.pop(li4),
),
),
],
).with_contents(
resources.items(),
default_specification=referencing.jsonschema.DRAFT202012,
)
object.__setattr__(self, "_remotes", registry)
def benchmark(self, runner: pyperf.Runner): # pragma: no cover

@@ -99,6 +70,14 @@ for name, Validator in _VALIDATORS.items():

def version(self, name) -> Version:
Validator = _VALIDATORS[name]
uri: str = Validator.ID_OF(Validator.META_SCHEMA) # type: ignore[assignment]
specification = referencing.jsonschema.specification_with(uri)
registry = Registry().with_contents(
remotes_in(root=self._root / "remotes", name=name, uri=uri),
default_specification=specification,
)
return Version(
name=name,
path=self._root / "tests" / name,
remotes=self._remotes,
remotes=registry,
)

@@ -195,2 +174,32 @@

def remotes_in(
root: Path,
name: str,
uri: str,
) -> Iterable[tuple[str, Schema]]:
# This messy logic is because the test suite is terrible at indicating
# what remotes are needed for what drafts, and mixes in schemas which
# have no $schema and which are invalid under earlier versions, in with
# other schemas which are needed for tests.
for each in root.rglob("*.json"):
schema = json.loads(each.read_text())
relative = str(each.relative_to(root)).replace("\\", "/")
if (
( # invalid boolean schema
name in {"draft3", "draft4"}
and each.stem == "tree"
) or
( # draft<NotThisDialect>/*.json
"$schema" not in schema
and relative.startswith("draft")
and not relative.startswith(name)
)
):
continue
yield f"{MAGIC_REMOTE_URL}/{relative}", schema
@frozen(repr=False)

@@ -197,0 +206,0 @@ class _Test:

@@ -693,3 +693,3 @@ from contextlib import redirect_stderr, redirect_stdout

def test_successful_validation_via_explicit_base_uri(self):
ref_schema_file = tempfile.NamedTemporaryFile(delete=False)
ref_schema_file = tempfile.NamedTemporaryFile(delete=False) # noqa: SIM115
ref_schema_file.close()

@@ -715,3 +715,3 @@ self.addCleanup(os.remove, ref_schema_file.name)

def test_unsuccessful_validation_via_explicit_base_uri(self):
ref_schema_file = tempfile.NamedTemporaryFile(delete=False)
ref_schema_file = tempfile.NamedTemporaryFile(delete=False) # noqa: SIM115
ref_schema_file.close()

@@ -886,7 +886,4 @@ self.addCleanup(os.remove, ref_schema_file.name)

def test_license(self):
output = subprocess.check_output(
[sys.executable, "-m", "pip", "show", "jsonschema"],
stderr=subprocess.STDOUT,
)
self.assertIn(b"License: MIT", output)
our_metadata = metadata.metadata("jsonschema")
self.assertEqual(our_metadata.get("License-Expression"), "MIT")

@@ -893,0 +890,0 @@ def test_version(self):

@@ -186,3 +186,3 @@ from contextlib import contextmanager

with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema.validators import RefResolver # noqa: F401, F811
from jsonschema.validators import RefResolver # noqa: F401
self.assertEqual(w.filename, __file__)

@@ -189,0 +189,0 @@

@@ -9,3 +9,2 @@ """

import sys

@@ -31,2 +30,7 @@ from jsonschema.tests._suite import Suite

def ecmascript_regex(test):
if test.subject == "ecmascript-regex":
return "ECMA regex support will be added in #1142."
def missing_format(Validator):

@@ -71,14 +75,2 @@ def missing_format(test): # pragma: no cover

if sys.version_info < (3, 9): # pragma: no cover
message = "Rejecting leading zeros is 3.9+"
allowed_leading_zeros = skip(
message=message,
subject="ipv4",
description="invalid leading zeroes, as they are treated as octals",
)
else:
def allowed_leading_zeros(test): # pragma: no cover
return
def leap_second(test):

@@ -138,3 +130,4 @@ message = "Leap seconds are unsupported."

skip=lambda test: (
missing_format(jsonschema.Draft3Validator)(test)
ecmascript_regex(test)
or missing_format(jsonschema.Draft3Validator)(test)
or complex_email_validation(test)

@@ -156,3 +149,3 @@ ),

skip=lambda test: (
allowed_leading_zeros(test)
ecmascript_regex(test)
or leap_second(test)

@@ -175,3 +168,3 @@ or missing_format(jsonschema.Draft4Validator)(test)

skip=lambda test: (
allowed_leading_zeros(test)
ecmascript_regex(test)
or leap_second(test)

@@ -196,3 +189,3 @@ or missing_format(jsonschema.Draft6Validator)(test)

skip=lambda test: (
allowed_leading_zeros(test)
ecmascript_regex(test)
or leap_second(test)

@@ -234,3 +227,3 @@ or missing_format(jsonschema.Draft7Validator)(test)

complex_email_validation(test)
or allowed_leading_zeros(test)
or ecmascript_regex(test)
or leap_second(test)

@@ -272,3 +265,3 @@ or missing_format(jsonschema.Draft201909Validator)(test)

complex_email_validation(test)
or allowed_leading_zeros(test)
or ecmascript_regex(test)
or leap_second(test)

@@ -275,0 +268,0 @@ or missing_format(jsonschema.Draft202012Validator)(test)

@@ -860,3 +860,3 @@ """

_LATEST_VERSION = Draft202012Validator
_LATEST_VERSION: type[Validator] = Draft202012Validator

@@ -1338,3 +1338,3 @@

schema,
default: Validator | _utils.Unset = _UNSET,
default: type[Validator] | _utils.Unset = _UNSET,
) -> type[Validator]:

@@ -1401,3 +1401,3 @@ """

if schema is True or schema is False or "$schema" not in schema:
return DefaultValidator
return DefaultValidator # type: ignore[return-value]
if schema["$schema"] not in _META_SCHEMAS and default is _UNSET:

@@ -1404,0 +1404,0 @@ warn(

[console_scripts]
jsonschema = jsonschema.cli:main
Copyright (c) 2013 Julian Berman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Metadata-Version: 2.3
Name: jsonschema
Version: 4.23.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/
Project-URL: Issues, https://github.com/python-jsonschema/jsonschema/issues/
Project-URL: Funding, https://github.com/sponsors/Julian
Project-URL: Tidelift, https://tidelift.com/subscription/pkg/pypi-jsonschema?utm_source=pypi-jsonschema&utm_medium=referral&utm_campaign=pypi-link
Project-URL: Changelog, https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst
Project-URL: Source, https://github.com/python-jsonschema/jsonschema
Author-email: Julian Berman <Julian+jsonschema@GrayVines.com>
License: MIT
License-File: COPYING
Keywords: data validation,json,json schema,jsonschema,validation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: File Formats :: JSON
Classifier: Topic :: File Formats :: JSON :: JSON Schema
Requires-Python: >=3.8
Requires-Dist: attrs>=22.2.0
Requires-Dist: importlib-resources>=1.4.0; python_version < '3.9'
Requires-Dist: jsonschema-specifications>=2023.03.6
Requires-Dist: pkgutil-resolve-name>=1.3.10; python_version < '3.9'
Requires-Dist: referencing>=0.28.4
Requires-Dist: rpds-py>=0.7.1
Provides-Extra: format
Requires-Dist: fqdn; extra == 'format'
Requires-Dist: idna; extra == 'format'
Requires-Dist: isoduration; extra == 'format'
Requires-Dist: jsonpointer>1.13; extra == 'format'
Requires-Dist: rfc3339-validator; extra == 'format'
Requires-Dist: rfc3987; extra == 'format'
Requires-Dist: uri-template; extra == 'format'
Requires-Dist: webcolors>=1.11; extra == 'format'
Provides-Extra: format-nongpl
Requires-Dist: fqdn; extra == 'format-nongpl'
Requires-Dist: idna; extra == 'format-nongpl'
Requires-Dist: isoduration; extra == 'format-nongpl'
Requires-Dist: jsonpointer>1.13; extra == 'format-nongpl'
Requires-Dist: rfc3339-validator; extra == 'format-nongpl'
Requires-Dist: rfc3986-validator>0.1.0; extra == 'format-nongpl'
Requires-Dist: uri-template; extra == 'format-nongpl'
Requires-Dist: webcolors>=24.6.0; extra == 'format-nongpl'
Description-Content-Type: text/x-rst
==========
jsonschema
==========
|PyPI| |Pythons| |CI| |ReadTheDocs| |Precommit| |Zenodo|
.. |PyPI| image:: https://img.shields.io/pypi/v/jsonschema.svg
:alt: PyPI version
:target: https://pypi.org/project/jsonschema/
.. |Pythons| image:: https://img.shields.io/pypi/pyversions/jsonschema.svg
:alt: Supported Python versions
:target: https://pypi.org/project/jsonschema/
.. |CI| image:: https://github.com/python-jsonschema/jsonschema/workflows/CI/badge.svg
:alt: Build status
:target: https://github.com/python-jsonschema/jsonschema/actions?query=workflow%3ACI
.. |ReadTheDocs| image:: https://readthedocs.org/projects/python-jsonschema/badge/?version=stable&style=flat
:alt: ReadTheDocs status
:target: https://python-jsonschema.readthedocs.io/en/stable/
.. |Precommit| image:: https://results.pre-commit.ci/badge/github/python-jsonschema/jsonschema/main.svg
:alt: pre-commit.ci status
:target: https://results.pre-commit.ci/latest/github/python-jsonschema/jsonschema/main
.. |Zenodo| image:: https://zenodo.org/badge/3072629.svg
:alt: Zenodo DOI
:target: https://zenodo.org/badge/latestdoi/3072629
``jsonschema`` is an implementation of the `JSON Schema <https://json-schema.org>`_ specification for Python.
.. code:: python
>>> from jsonschema import validate
>>> # A sample schema, like what we'd get from json.load()
>>> schema = {
... "type" : "object",
... "properties" : {
... "price" : {"type" : "number"},
... "name" : {"type" : "string"},
... },
... }
>>> # If no exception is raised by validate(), the instance is valid.
>>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema)
>>> validate(
... instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema,
... ) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValidationError: 'Invalid' is not of type 'number'
It can also be used from the command line by installing `check-jsonschema <https://github.com/python-jsonschema/check-jsonschema>`_.
Features
--------
* Full support for `Draft 2020-12 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft202012Validator>`_, `Draft 2019-09 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft201909Validator>`_, `Draft 7 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft7Validator>`_, `Draft 6 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft6Validator>`_, `Draft 4 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft4Validator>`_ and `Draft 3 <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/validators/#jsonschema.validators.Draft3Validator>`_
* `Lazy validation <https://python-jsonschema.readthedocs.io/en/latest/api/jsonschema/protocols/#jsonschema.protocols.Validator.iter_errors>`_ that can iteratively report *all* validation errors.
* `Programmatic querying <https://python-jsonschema.readthedocs.io/en/latest/errors/>`_ of which properties or items failed validation.
Installation
------------
``jsonschema`` is available on `PyPI <https://pypi.org/project/jsonschema/>`_. You can install using `pip <https://pip.pypa.io/en/stable/>`_:
.. code:: bash
$ pip install jsonschema
Extras
======
Two extras are available when installing the package, both currently related to ``format`` validation:
* ``format``
* ``format-nongpl``
They can be used when installing in order to include additional dependencies, e.g.:
.. code:: bash
$ 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
-----
I'm Julian Berman.
``jsonschema`` is on `GitHub <https://github.com/python-jsonschema/jsonschema>`_.
Get in touch, via GitHub or otherwise, if you've got something to contribute, it'd be most welcome!
You can also generally find me on Libera (nick: ``Julian``) in various channels, including ``#python``.
If you feel overwhelmingly grateful, you can also `sponsor me <https://github.com/sponsors/Julian/>`_.
And for companies who appreciate ``jsonschema`` and its continued support and growth, ``jsonschema`` is also now supportable via `TideLift <https://tidelift.com/subscription/pkg/pypi-jsonschema?utm_source=pypi-jsonschema&utm_medium=referral&utm_campaign=readme>`_.
Release Information
-------------------
v4.23.0
=======
* Do not reorder dictionaries (schemas, instances) that are printed as part of validation errors.
* Declare support for Py3.13
jsonschema/__init__.py,sha256=LkPwscySlJ9lTOp7ZB1M7jQ8mbG7-bYG41iBwbZ-o9s,3941
jsonschema/__main__.py,sha256=iLsZf2upUB3ilBKTlMnyK-HHt2Cnnfkwwxi_c6gLvSA,115
jsonschema/_format.py,sha256=F_MA52IkrhOIxDqD8x-01bH37mG5nh0kyNrWUSLtWb8,14591
jsonschema/_keywords.py,sha256=r8_DrqAfn6QLwQnmXEggveiSU-UaIL2p2nuPINelfFc,14949
jsonschema/_legacy_keywords.py,sha256=2tWuwRPWbYS7EAl8wBIC_rabGuv1J4dfYLqNEPpShhA,15191
jsonschema/_types.py,sha256=HQ5QD_oL85zF1FSW2v-5rvfYF0967HJdxSR88kzw2mY,5367
jsonschema/_typing.py,sha256=NZhPhkBOn9INYZk8G69rDeuRamztgXCMLh10z9cfT6g,610
jsonschema/_utils.py,sha256=ODga3vrJ6K2wMGxerpgn4ipc9q7ZSqBsvwKU4embLEE,10642
jsonschema/cli.py,sha256=SGy9JPg02mgXhNxugU8iXhYNivfSjBhKTNAgV90ty-M,8551
jsonschema/exceptions.py,sha256=RxE2T5xxgg_B6ttR8a3lCbZyh29RUtFe4oZKMoHPBAE,15035
jsonschema/protocols.py,sha256=7mpZxO1gfRNMCGXwldwsSN3nEugVfIVyKZ_HZgN1vSw,7174
jsonschema/validators.py,sha256=H31FwHdyB7LP5eunxdBrZ9E57hpvozfnRlZaOYy45jU,47045
jsonschema/benchmarks/__init__.py,sha256=A0sQrxDBVHSyQ-8ru3L11hMXf3q9gVuB9x_YgHb4R9M,70
jsonschema/benchmarks/const_vs_enum.py,sha256=DVFi3WDqBalZFOibnjpX1uTSr3Rxa2cPgFcowd7Ukrs,830
jsonschema/benchmarks/contains.py,sha256=gexQoUrCOwECofbt19BeosQZ7WFL6PDdkX49DWwBlOg,786
jsonschema/benchmarks/issue232.py,sha256=3LLYLIlBGQnVuyyo2iAv-xky5P6PRFHANx4-zIIQOoE,521
jsonschema/benchmarks/json_schema_test_suite.py,sha256=PvfabpUYcF4_7csYDTcTauED8rnFEGYbdY5RqTXD08s,320
jsonschema/benchmarks/nested_schemas.py,sha256=mo07dx-CIgmSOI62CNs4g5xu1FzHklLBpkQoDxWYcKs,1892
jsonschema/benchmarks/subcomponents.py,sha256=fEyiMzsWeK2pd7DEGCuuY-vzGunwhHczRBWEnBRLKIo,1113
jsonschema/benchmarks/unused_registry.py,sha256=hwRwONc9cefPtYzkoX_TYRO3GyUojriv0-YQaK3vnj0,940
jsonschema/benchmarks/useless_applicator_schemas.py,sha256=EVm5-EtOEFoLP_Vt2j4SrCwlx05NhPqNuZQ6LIMP1Dc,3342
jsonschema/benchmarks/useless_keywords.py,sha256=bj_zKr1oVctFlqyZaObCsYTgFjiiNgPzC0hr1Y868mE,867
jsonschema/benchmarks/validator_creation.py,sha256=UkUQlLAnussnr_KdCIdad6xx2pXxQLmYtsXoiirKeWQ,285
jsonschema/benchmarks/issue232/issue.json,sha256=eaPOZjMRu5u8RpKrsA9uk7ucPZS5tkKG4D_hkOTQ3Hk,117105
jsonschema/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
jsonschema/tests/_suite.py,sha256=QAfBj34zMbJQ5_JJ2ogpiTlw9hQ6Is43dvo_bpS0EdM,8156
jsonschema/tests/fuzz_validate.py,sha256=fUA7yTJIihaCwJplkUehZeyB84HcXEcqtY5oPJXIO7I,1114
jsonschema/tests/test_cli.py,sha256=uFMu2YbIfbSDCnykhLL4-VR3-jg1tvQLJn2Bliwp_Bw,28587
jsonschema/tests/test_deprecations.py,sha256=9VxOCfWzMG1Tg4OD8riU_Znd6HDOQZkepzVgxsdUdU8,15760
jsonschema/tests/test_exceptions.py,sha256=JgC-E1ZFZK2puVBp35WFRnG8CNOiSWLYtyLjh9IvFKI,22591
jsonschema/tests/test_format.py,sha256=eVm5SMaWF2lOPO28bPAwNvkiQvHCQKy-MnuAgEchfEc,3188
jsonschema/tests/test_jsonschema_test_suite.py,sha256=a2saPs2Cwwg0sdRdu-uJ8goSXLbqrS-pC48QJy0K4DE,8674
jsonschema/tests/test_types.py,sha256=cF51KTDmdsx06MrIc4fXKt0X9fIsVgw5uhT8CamVa8U,6977
jsonschema/tests/test_utils.py,sha256=sao74o1PyYMxBfqweokQN48CFSS6yhJk5FkCfMJ5PsI,4163
jsonschema/tests/test_validators.py,sha256=eiaigsZMzHYYsniQ1UPygaS56a1d-_7-9NC4wVXAhzs,87975
jsonschema-4.23.0.dist-info/METADATA,sha256=Hd96gAfdO0v5RpFeT25qjyo7PvhASy56F4Jw3FUUTlo,7906
jsonschema-4.23.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
jsonschema-4.23.0.dist-info/entry_points.txt,sha256=vO7rX4Fs_xIVJy2pnAtKgTSxfpnozAVQ0DjCmpMxnWE,51
jsonschema-4.23.0.dist-info/licenses/COPYING,sha256=T5KgFaE8TRoEC-8BiqE0MLTxvHO0Gxa7hGw0Z2bedDk,1057
jsonschema-4.23.0.dist-info/RECORD,,
Wheel-Version: 1.0
Generator: hatchling 1.25.0
Root-Is-Purelib: true
Tag: py3-none-any