From 080e9624e11bebe0c9e3e4a97c2564f39af0a18f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:19:47 +0000 Subject: [PATCH 01/28] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80c0c3e..0b69c7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - name: black id: black From 6af53436c23e11ec0a1ac5d8327b3658b42e86f1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:20:14 +0000 Subject: [PATCH 02/28] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- referencing/__init__.py | 1 + referencing/_core.py | 8 ++++---- referencing/exceptions.py | 1 + referencing/retrieval.py | 1 + referencing/typing.py | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/referencing/__init__.py b/referencing/__init__.py index c4476d4..e09207d 100644 --- a/referencing/__init__.py +++ b/referencing/__init__.py @@ -1,6 +1,7 @@ """ Cross-specification, implementation-agnostic JSON referencing. """ + from referencing._core import Anchor, Registry, Resource, Specification __all__ = ["Anchor", "Registry", "Resource", "Specification"] diff --git a/referencing/_core.py b/referencing/_core.py index 9443715..b33276f 100644 --- a/referencing/_core.py +++ b/referencing/_core.py @@ -33,8 +33,7 @@ def __call__( segments: Sequence[int | str], resolver: Resolver[D], subresource: Resource[D], - ) -> Resolver[D]: - ... + ) -> Resolver[D]: ... def _detect_or_error(contents: D) -> Specification[D]: @@ -192,8 +191,9 @@ class Resource(Generic[D]): def from_contents( cls, contents: D, - default_specification: type[Specification[D]] - | Specification[D] = Specification, + default_specification: ( + type[Specification[D]] | Specification[D] + ) = Specification, ) -> Resource[D]: """ Create a resource guessing which specification applies to the contents. diff --git a/referencing/exceptions.py b/referencing/exceptions.py index a893d45..3267fc7 100644 --- a/referencing/exceptions.py +++ b/referencing/exceptions.py @@ -1,6 +1,7 @@ """ Errors, oh no! """ + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/referencing/retrieval.py b/referencing/retrieval.py index 589f1f8..e3719cf 100644 --- a/referencing/retrieval.py +++ b/referencing/retrieval.py @@ -1,6 +1,7 @@ """ Helpers related to (dynamic) resource retrieval. """ + from __future__ import annotations from functools import lru_cache diff --git a/referencing/typing.py b/referencing/typing.py index ad807a3..d00b018 100644 --- a/referencing/typing.py +++ b/referencing/typing.py @@ -1,6 +1,7 @@ """ Type-annotation related support for the referencing library. """ + from __future__ import annotations from typing import TYPE_CHECKING, Protocol, TypeVar From 4d49a56237cf89cce9bbe7c5ceafa4533c54c70b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:12:53 +0000 Subject: [PATCH 03/28] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.14...v0.2.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b69c7a..137ad4d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.14" + rev: "v0.2.0" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From d310e8b8a5211bc35158a834f18488347bf69eb0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:13:10 +0000 Subject: [PATCH 04/28] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- referencing/_core.py | 4 ++++ referencing/jsonschema.py | 1 + referencing/typing.py | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/referencing/_core.py b/referencing/_core.py index b33276f..04014b4 100644 --- a/referencing/_core.py +++ b/referencing/_core.py @@ -205,6 +205,7 @@ def from_contents( if the given contents don't have any discernible information which could be used to guess which specification they identify as + """ specification = default_specification.detect(contents) return specification.create_resource(contents=contents) @@ -254,6 +255,7 @@ def pointer(self, pointer: str, resolver: Resolver[D]) -> Resolved[D]: `exceptions.PointerToNowhere` if the pointer points to a location not present in the document + """ contents = self.contents segments: list[int | str] = [] @@ -369,6 +371,7 @@ def __rmatmul__( `NoInternalID` if the resource(s) in fact do not have IDs + """ if isinstance(new, Resource): new = (new,) @@ -658,6 +661,7 @@ def lookup(self, ref: URI) -> Resolved[D]: if the reference is to a URI where a resource exists but contains a JSON pointer to a location within the resource that does not exist + """ if ref.startswith("#"): uri, fragment = self._base_uri, ref[1:] diff --git a/referencing/jsonschema.py b/referencing/jsonschema.py index 564f4d2..f66145f 100644 --- a/referencing/jsonschema.py +++ b/referencing/jsonschema.py @@ -575,6 +575,7 @@ def specification_with( `UnknownDialect` if the given ``dialect_id`` isn't known + """ resource = _SPECIFICATIONS.get(dialect_id.rstrip("#")) if resource is not None: diff --git a/referencing/typing.py b/referencing/typing.py index d00b018..7f94e64 100644 --- a/referencing/typing.py +++ b/referencing/typing.py @@ -38,7 +38,6 @@ def __call__(self, uri: URI) -> Resource[D]: Raise `referencing.exceptions.NoSuchResource` if you wish to indicate the retriever cannot lookup the given URI. """ - ... class Anchor(Protocol[D]): @@ -54,10 +53,8 @@ def name(self) -> str: """ Return the name of this anchor. """ - ... def resolve(self, resolver: Resolver[D]) -> Resolved[D]: """ Return the resource for this anchor. """ - ... From 7102bd5300d27b75c855972206df209145006316 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 5 Feb 2024 13:33:25 -0500 Subject: [PATCH 05/28] Add a link to the changelog on PyPI. --- noxfile.py | 4 +++- pyproject.toml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 2434617..6980190 100644 --- a/noxfile.py +++ b/noxfile.py @@ -154,7 +154,9 @@ def docs_style(session): @session(default=False) def requirements(session): """ - Update the project's pinned requirements. Commit the result. + Update the project's pinned requirements. + + You should commit the result afterwards. """ session.install("pip-tools") for each in REQUIREMENTS_IN: diff --git a/pyproject.toml b/pyproject.toml index 32b99be..f620e80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ Homepage = "https://github.com/python-jsonschema/referencing" Issues = "https://github.com/python-jsonschema/referencing/issues/" Funding = "https://github.com/sponsors/Julian" Tidelift = "https://tidelift.com/subscription/pkg/pypi-referencing?utm_source=pypi-referencing&utm_medium=referral&utm_campaign=pypi-link" +Changelog = "https://referencing.readthedocs.io/en/stable/changes/" Source = "https://github.com/python-jsonschema/referencing" [tool.coverage.html] From 11ff8101461de4026331340645eae22a31fc9ea8 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 5 Feb 2024 13:39:13 -0500 Subject: [PATCH 06/28] Ruff deprecation noise. --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f620e80..8e18916 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,6 +89,9 @@ exclude = [ [tool.ruff] line-length = 79 +extend-exclude = ["suite"] + +[tool.ruff.lint] select = ["ALL"] ignore = [ "A001", # It's fine to shadow builtins @@ -133,19 +136,18 @@ ignore = [ "TD", # These TODO style rules are also silly "UP007", # We support 3.8 + 3.9 ] -extend-exclude = ["suite"] [tool.ruff.lint.flake8-pytest-style] mark-parentheses = false -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" [tool.ruff.lint.isort] combine-as-imports = true from-first = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "noxfile.py" = ["ANN", "D100", "S101", "T201"] "docs/*" = ["ANN", "D", "INP001"] "referencing/tests/*" = ["ANN", "D", "RUF012", "S", "PLR", "TRY"] From a6c8f62a322696d000eadfbed315fd1f05d18620 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 5 Feb 2024 13:43:25 -0500 Subject: [PATCH 07/28] pyright noise This seems somehow caused by astral-sh/ruff#8756, which is marked closed. Here comes a rabbit hole to find out why this cropped up now. --- referencing/typing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/referencing/typing.py b/referencing/typing.py index 7f94e64..d00b018 100644 --- a/referencing/typing.py +++ b/referencing/typing.py @@ -38,6 +38,7 @@ def __call__(self, uri: URI) -> Resource[D]: Raise `referencing.exceptions.NoSuchResource` if you wish to indicate the retriever cannot lookup the given URI. """ + ... class Anchor(Protocol[D]): @@ -53,8 +54,10 @@ def name(self) -> str: """ Return the name of this anchor. """ + ... def resolve(self, resolver: Resolver[D]) -> Resolved[D]: """ Return the resource for this anchor. """ + ... From c6146a3f0fce1263246f50186d43099090f55a28 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Feb 2024 11:22:16 -0500 Subject: [PATCH 08/28] Also check the noxfile in the style env. --- noxfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 6980190..d77e3bf 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,8 +17,8 @@ path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values() ] -SUPPORTED = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"] -LATEST = "3.12" +SUPPORTED = ["3.8", "3.9", "3.10", "pypy3.10", "3.11", "3.12"] +LATEST = SUPPORTED[-1] nox.options.sessions = [] @@ -89,7 +89,7 @@ def style(session): Check Python code style. """ session.install("ruff") - session.run("ruff", "check", ROOT) + session.run("ruff", "check", ROOT, __file__) @session() From 4afc0d50f8dd616bb762a6e2cc2d679ba2202334 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Feb 2024 11:22:31 -0500 Subject: [PATCH 09/28] Pass posargs through to pyright in the typing noxenv. --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index d77e3bf..b121263 100644 --- a/noxfile.py +++ b/noxfile.py @@ -98,7 +98,7 @@ def typing(session): Check static typing. """ session.install("pyright", ROOT) - session.run("pyright", REFERENCING) + session.run("pyright", *session.posargs, REFERENCING) @session(tags=["docs"]) From 56c46764cca27d88137d1f7d8708348bda4193bc Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Feb 2024 11:34:45 -0500 Subject: [PATCH 10/28] Let pre-commit.ci run pre-commit, and update hooks. --- .github/workflows/ci.yml | 9 --------- .pre-commit-config.yaml | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51aea73..ba178e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,15 +14,6 @@ env: PIP_NO_PYTHON_VERSION_WARNING: "1" jobs: - pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - uses: pre-commit/action@v3.0.0 - list: runs-on: ubuntu-latest outputs: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 137ad4d..a805495 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.0" + rev: "v0.2.1" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 45fb7cda337f3145666b85a097f3342e8dc7b8b8 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Feb 2024 12:26:25 -0500 Subject: [PATCH 11/28] One battle of the linters appears resolved. --- .pre-commit-config.yaml | 4 ---- pyproject.toml | 2 +- referencing/jsonschema.py | 9 ++++++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a805495..4cdc022 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,10 +17,6 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - repo: https://github.com/psf/black rev: 24.1.1 hooks: diff --git a/pyproject.toml b/pyproject.toml index 8e18916..db0a6bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,6 +99,7 @@ ignore = [ "A003", "ARG", # This is all wrong whenever an interface is involved "ANN", # Just let the type checker do this + "B006", # Mutable arguments require care but are OK if you don't abuse them "B008", # It's totally OK to call functions for default arguments. "B904", # raise SomeException(...) is fine. "B905", # No need for explicit strict, this is simply zip's default behavior @@ -118,7 +119,6 @@ ignore = [ "EM102", "FBT", # It's worth avoiding boolean args but I don't care to enforce it "FIX", # Yes thanks, if I could it wouldn't be there - "I001", # We can't yet use ruff's isort "N", # These naming rules are silly "PLR0912", # These metrics are fine to be aware of but not to enforce "PLR0913", diff --git a/referencing/jsonschema.py b/referencing/jsonschema.py index f66145f..ff4b43f 100644 --- a/referencing/jsonschema.py +++ b/referencing/jsonschema.py @@ -9,9 +9,12 @@ from referencing import Anchor, Registry, Resource, Specification, exceptions from referencing._attrs import frozen -from referencing._core import _UNSET # type: ignore[reportPrivateUsage] -from referencing._core import _Unset # type: ignore[reportPrivateUsage] -from referencing._core import Resolved as _Resolved, Resolver as _Resolver +from referencing._core import ( + _UNSET, # type: ignore[reportPrivateUsage] + Resolved as _Resolved, + Resolver as _Resolver, + _Unset, # type: ignore[reportPrivateUsage] +) from referencing.typing import URI, Anchor as AnchorType, Mapping #: A JSON Schema which is a JSON object From 7d6069a7dfa76be679b02587b1ba89a0bfe7348d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Feb 2024 12:33:27 -0500 Subject: [PATCH 12/28] Update docs requirements. --- docs/requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 8ad07f9..b72dedc 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -12,13 +12,13 @@ babel==2.14.0 # via sphinx beautifulsoup4==4.12.3 # via furo -certifi==2023.11.17 +certifi==2024.2.2 # via requests charset-normalizer==3.3.2 # via requests docutils==0.20.1 # via sphinx -furo==2023.9.10 +furo==2024.1.29 # via -r docs/requirements.in idna==3.6 # via requests @@ -28,7 +28,7 @@ jinja2==3.1.3 # via sphinx lxml==5.1.0 # via sphinx-json-schema-spec -markupsafe==2.1.4 +markupsafe==2.1.5 # via jinja2 packaging==23.2 # via sphinx @@ -84,5 +84,5 @@ sphinxext-opengraph==0.9.1 # via -r docs/requirements.in url-py==0.10.0 # via -r docs/requirements.in -urllib3==2.1.0 +urllib3==2.2.0 # via requests From 73fccb2e12a511400ba36100fe333c6803bfdfe8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:36:05 +0000 Subject: [PATCH 13/28] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.1.1 → 24.2.0](https://github.com/psf/black/compare/24.1.1...24.2.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4cdc022..3cf1562 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 24.1.1 + rev: 24.2.0 hooks: - name: black id: black From 7ff3f9129635e440e2da9eb040c069ec45fa4bf2 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 18 Feb 2024 08:55:38 -0500 Subject: [PATCH 14/28] Obsolete type ignores. --- referencing/_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/referencing/_core.py b/referencing/_core.py index 04014b4..e6da867 100644 --- a/referencing/_core.py +++ b/referencing/_core.py @@ -552,8 +552,8 @@ def combine(self, *registries: Registry[D]) -> Registry[D]: uncrawled = self._uncrawled retrieve = self._retrieve for registry in registries: - resources = resources.update(registry._resources) # type: ignore[reportUnknownMemberType] - anchors = anchors.update(registry._anchors) # type: ignore[reportUnknownMemberType] + resources = resources.update(registry._resources) + anchors = anchors.update(registry._anchors) uncrawled = uncrawled.update(registry._uncrawled) if registry._retrieve is not _fail_to_retrieve: From f3ae00fb6319486d4f60fef0aebbdc158c1b3479 Mon Sep 17 00:00:00 2001 From: James Cobb-Walsh Date: Sun, 18 Feb 2024 20:42:30 +0000 Subject: [PATCH 15/28] Minimal mypy config in pyproject.toml --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index db0a6bc..ffb7e5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,6 +79,10 @@ include_trailing_comma = true multi_line_output = 3 use_parentheses = true +[tool.mypy] +follow_imports = "skip" +ignore_errors = true + [tool.pyright] reportUnnecessaryTypeIgnoreComment = true strict = ["**/*"] From 5c83b9b9a82242b88b79ab8579cd1e5aaefa3003 Mon Sep 17 00:00:00 2001 From: James Cobb-Walsh Date: Sun, 18 Feb 2024 22:24:34 +0000 Subject: [PATCH 16/28] Add mypy to noxfile --- noxfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/noxfile.py b/noxfile.py index b121263..3a276fb 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,6 +101,15 @@ def typing(session): session.run("pyright", *session.posargs, REFERENCING) +@session() +def mypy(session): + """ + Check that mypy runs with no blocking errors. + """ + session.install("mypy", ROOT) + session.run("mypy", REFERENCING) + + @session(tags=["docs"]) @nox.parametrize( "builder", From e715da56f33b72f80e79f247046dd08af8211a1d Mon Sep 17 00:00:00 2001 From: James Cobb-Walsh Date: Mon, 19 Feb 2024 07:59:43 +0000 Subject: [PATCH 17/28] Fix invalid type ignore comment syntax --- referencing/jsonschema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/referencing/jsonschema.py b/referencing/jsonschema.py index ff4b43f..2eb1647 100644 --- a/referencing/jsonschema.py +++ b/referencing/jsonschema.py @@ -432,7 +432,7 @@ def maybe_in_subresource( "properties", }, ), - anchors_in=_anchor_2019, # type: ignore[reportGeneralTypeIssues] TODO: check whether this is real + anchors_in=_anchor_2019, # type: ignore[reportGeneralTypeIssues] # TODO: check whether this is real maybe_in_subresource=_maybe_in_subresource_crazy_items( in_value={ "additionalItems", @@ -474,7 +474,7 @@ def maybe_in_subresource( in_subarray={"allOf", "anyOf", "oneOf"}, in_subvalues={"definitions", "patternProperties", "properties"}, ), - anchors_in=_legacy_anchor_in_dollar_id, # type: ignore[reportGeneralTypeIssues] TODO: check whether this is real + anchors_in=_legacy_anchor_in_dollar_id, # type: ignore[reportGeneralTypeIssues] # TODO: check whether this is real maybe_in_subresource=_maybe_in_subresource_crazy_items_dependencies( in_value={ "additionalItems", @@ -505,7 +505,7 @@ def maybe_in_subresource( in_subarray={"allOf", "anyOf", "oneOf"}, in_subvalues={"definitions", "patternProperties", "properties"}, ), - anchors_in=_legacy_anchor_in_dollar_id, # type: ignore[reportGeneralTypeIssues] TODO: check whether this is real + anchors_in=_legacy_anchor_in_dollar_id, # type: ignore[reportGeneralTypeIssues] # TODO: check whether this is real maybe_in_subresource=_maybe_in_subresource_crazy_items_dependencies( in_value={ "additionalItems", From bd4ba31c7885b762d0ab464c9d99553ddee0959c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:25:15 +0000 Subject: [PATCH 18/28] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.1 → v0.2.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.1...v0.2.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3cf1562..aadbb76 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.1" + rev: "v0.2.2" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 0acda18f019c4134e2bbdad2e275f907a52cf0cc Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 21 Feb 2024 08:55:50 -0500 Subject: [PATCH 19/28] I'm one person, not two. --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ffb7e5c..02d4cf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,8 +13,7 @@ readme = "README.rst" license = {text = "MIT"} keywords = ["json", "referencing", "jsonschema", "openapi", "asyncapi"] authors = [ - {email = "Julian+referencing@GrayVines.com"}, - {name = "Julian Berman"}, + { name = "Julian Berman", email = "Julian+referencing@GrayVines.com" }, ] classifiers = [ "Development Status :: 3 - Alpha", From 4f00eb0b9947c28926792fc64f497343ea3a5af3 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 25 Feb 2024 22:52:56 -0500 Subject: [PATCH 20/28] The packaging docs apparently discourage license. They say to just use the classifier. --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 02d4cf7..1557af1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,6 @@ name = "referencing" description = "JSON Referencing + Python" requires-python = ">=3.8" readme = "README.rst" -license = {text = "MIT"} keywords = ["json", "referencing", "jsonschema", "openapi", "asyncapi"] authors = [ { name = "Julian Berman", email = "Julian+referencing@GrayVines.com" }, From 3657c80effd164475a2fe6c6872c18f77d208598 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 01:08:32 +0000 Subject: [PATCH 21/28] Bump wntrblm/nox from 2023.04.22 to 2024.03.02 Bumps [wntrblm/nox](https://github.com/wntrblm/nox) from 2023.04.22 to 2024.03.02. - [Release notes](https://github.com/wntrblm/nox/releases) - [Changelog](https://github.com/wntrblm/nox/blob/main/CHANGELOG.md) - [Commits](https://github.com/wntrblm/nox/compare/2023.04.22...2024.03.02) --- updated-dependencies: - dependency-name: wntrblm/nox dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba178e8..e5c2892 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up nox - uses: wntrblm/nox@2023.04.22 + uses: wntrblm/nox@2024.03.02 - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( @@ -62,7 +62,7 @@ jobs: pypy3.10 allow-prereleases: true - name: Set up nox - uses: wntrblm/nox@2023.04.22 + uses: wntrblm/nox@2024.03.02 - name: Run nox run: nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }} From 542e4d3523eb263153b84b52b70dc55c55ee9809 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 5 Mar 2024 15:20:34 -0500 Subject: [PATCH 22/28] Minor workflow tweak, enabling caching and saving a double build. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5c2892..3bc637b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: CI on: push: + tags: + - "v*" pull_request: release: types: [published] @@ -61,6 +63,7 @@ jobs: 3.12 pypy3.10 allow-prereleases: true + cache: pip - name: Set up nox uses: wntrblm/nox@2024.03.02 - name: Run nox @@ -83,6 +86,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: + cache: pip python-version: "3.x" - name: Install dependencies run: python -m pip install build From 51858ea0db9654e46e158e4f07fd665e41dc5da0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 01:01:19 +0000 Subject: [PATCH 23/28] Bump softprops/action-gh-release from 1 to 2 Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2. - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bc637b..9bca556 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 - name: Create a Release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | dist/* From 23e2a7ef7544f008ca29901724dc7387c2fda2f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:11:17 +0000 Subject: [PATCH 24/28] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aadbb76..98ecd4c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.2" + rev: "v0.3.2" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 55a1ccfa90a49a754b0d188daf246230890f2809 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 16 Mar 2024 08:48:50 -0400 Subject: [PATCH 25/28] Mark the normalization tests xfailed so we can update the suite. Refs: #75 --- referencing/tests/test_referencing_suite.py | 3 +++ suite | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/referencing/tests/test_referencing_suite.py b/referencing/tests/test_referencing_suite.py index a3d0783..4b8ae91 100644 --- a/referencing/tests/test_referencing_suite.py +++ b/referencing/tests/test_referencing_suite.py @@ -46,6 +46,9 @@ def test_referencing_suite(test_path, subtests): ) for test in loaded["tests"]: with subtests.test(test=test): + if "normalization" in test_path.stem: + pytest.xfail("APIs need to change for proper URL support.") + resolver = registry.resolver(base_uri=test.get("base_uri", "")) if test.get("error"): diff --git a/suite b/suite index 9153b05..e3fe0aa 160000 --- a/suite +++ b/suite @@ -1 +1 @@ -Subproject commit 9153b054a9e936587eb514e4466c1886645278c4 +Subproject commit e3fe0aa59667bcc34b3c1be42aaed7ee685df846 From 685e34c729243d68f3f262f1167b8296d6288a96 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 16 Mar 2024 08:49:47 -0400 Subject: [PATCH 26/28] Look for subschemas in `definitions`, even in newer dialects. Even though `definitions` was renamed to `$defs`, the JSON Schema specifications still use SHOULD language when describing preserving behavior for `definitions`. Specifically they say: implementations SHOULD assume that "$defs" and "definitions" have the same behavior when that meta-schema is used. from https://json-schema.org/draft/2020-12/json-schema-validation#name-keywords-moved-from-validat Closes: #129 --- docs/changes.rst | 6 ++++++ referencing/jsonschema.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/docs/changes.rst b/docs/changes.rst index 6a43ab8..9575f40 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -2,6 +2,12 @@ Changelog ========= +v0.34.0 +------- + +* Also look inside ``definitions`` keywords even on newer dialects. + The specification recommends doing so regardless of the rename to ``$defs``. + v0.33.0 ------- diff --git a/referencing/jsonschema.py b/referencing/jsonschema.py index 2eb1647..fb8668a 100644 --- a/referencing/jsonschema.py +++ b/referencing/jsonschema.py @@ -377,6 +377,7 @@ def maybe_in_subresource( in_subarray={"allOf", "anyOf", "oneOf", "prefixItems"}, in_subvalues={ "$defs", + "definitions", "dependentSchemas", "patternProperties", "properties", @@ -400,6 +401,7 @@ def maybe_in_subresource( in_subarray={"allOf", "anyOf", "oneOf", "prefixItems"}, in_subvalues={ "$defs", + "definitions", "dependentSchemas", "patternProperties", "properties", @@ -427,6 +429,7 @@ def maybe_in_subresource( in_subarray={"allOf", "anyOf", "oneOf"}, in_subvalues={ "$defs", + "definitions", "dependentSchemas", "patternProperties", "properties", @@ -450,6 +453,7 @@ def maybe_in_subresource( in_subarray={"allOf", "anyOf", "oneOf"}, in_subvalues={ "$defs", + "definitions", "dependentSchemas", "patternProperties", "properties", From 022d43a4e23073ddb415057bb93c5938546532ac Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 16 Mar 2024 08:56:26 -0400 Subject: [PATCH 27/28] Disallow pyright==1.1.354 until microsoft/pyright#7489 is fixed. --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 3a276fb..52b949c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -97,7 +97,7 @@ def typing(session): """ Check static typing. """ - session.install("pyright", ROOT) + session.install("pyright!=1.1.354", ROOT) session.run("pyright", *session.posargs, REFERENCING) From 499e67e84bb7d34aab009a758e6eac97d499ab4a Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 16 Mar 2024 08:57:21 -0400 Subject: [PATCH 28/28] Update pre-commit hooks. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98ecd4c..07eac3c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,12 +13,12 @@ repos: args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.3.3" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.3.0 hooks: - name: black id: black