From 43cb7ad4fb087f1f3c71d9daceb714bce2d7b13f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 00:09:10 +0000 Subject: [PATCH 01/12] Bump suite from `e3fe0aa` to `d3fdf35` Bumps [suite](https://github.com/python-jsonschema/referencing-suite) from `e3fe0aa` to `d3fdf35`. - [Commits](https://github.com/python-jsonschema/referencing-suite/compare/e3fe0aa59667bcc34b3c1be42aaed7ee685df846...d3fdf357f54dcaf1f22c6c30d3f26955fc16e70e) --- updated-dependencies: - dependency-name: suite dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- suite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite b/suite index e3fe0aa..d3fdf35 160000 --- a/suite +++ b/suite @@ -1 +1 @@ -Subproject commit e3fe0aa59667bcc34b3c1be42aaed7ee685df846 +Subproject commit d3fdf357f54dcaf1f22c6c30d3f26955fc16e70e From a0de1d5751865bd058694a3147b4c2c974d18ee0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:23:52 +0000 Subject: [PATCH 02/12] [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.3.3 → v0.3.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.3.3...v0.3.4) --- .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 07eac3c..b807310 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.3.3" + rev: "v0.3.4" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 4e65e5d03bd8bbf5aa8542ad6e7fcbda818d4582 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 00:54:49 +0000 Subject: [PATCH 03/12] Bump suite from `d3fdf35` to `71c85d0` Bumps [suite](https://github.com/python-jsonschema/referencing-suite) from `d3fdf35` to `71c85d0`. - [Commits](https://github.com/python-jsonschema/referencing-suite/compare/d3fdf357f54dcaf1f22c6c30d3f26955fc16e70e...71c85d053a433f97e497a4436a024c7856b31d24) --- updated-dependencies: - dependency-name: suite dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- suite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite b/suite index d3fdf35..71c85d0 160000 --- a/suite +++ b/suite @@ -1 +1 @@ -Subproject commit d3fdf357f54dcaf1f22c6c30d3f26955fc16e70e +Subproject commit 71c85d053a433f97e497a4436a024c7856b31d24 From c0b176fd62e04018aff2872a42e720d8f2caf470 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 25 Mar 2024 21:03:39 -0400 Subject: [PATCH 04/12] Whatever pyright regression was present is still present. So pin from above until we are bored enough to look into it. --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 52b949c..daee639 100644 --- a/noxfile.py +++ b/noxfile.py @@ -97,7 +97,7 @@ def typing(session): """ Check static typing. """ - session.install("pyright!=1.1.354", ROOT) + session.install("pyright<1.1.354", ROOT) session.run("pyright", *session.posargs, REFERENCING) From d5d037624d4e1edfdf8de15e33f14ff1d360257d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:37:51 +0000 Subject: [PATCH 05/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) - [github.com/astral-sh/ruff-pre-commit: v0.3.4 → v0.3.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.3.4...v0.3.7) - [github.com/psf/black: 24.3.0 → 24.4.0](https://github.com/psf/black/compare/24.3.0...24.4.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b807310..8780e82 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-ast - id: check-docstring-first @@ -13,12 +13,12 @@ repos: args: [--fix, lf] - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.4" + rev: "v0.3.7" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 24.3.0 + rev: 24.4.0 hooks: - name: black id: black From d031bce2b260c9d1fddac11db11691035e227d62 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 21 Apr 2024 19:40:26 +0300 Subject: [PATCH 06/12] Use uv for envs, particularly the requirements env. Faster, etc. --- docs/requirements.txt | 33 ++++++++++----------------------- noxfile.py | 23 ++++++++++++----------- test-requirements.txt | 26 +++++++++----------------- 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index b72dedc..b4228b8 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,9 +1,5 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile --strip-extras docs/requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile --output-file docs/requirements.txt docs/requirements.in alabaster==0.7.16 # via sphinx attrs==23.2.0 @@ -16,21 +12,20 @@ certifi==2024.2.2 # via requests charset-normalizer==3.3.2 # via requests -docutils==0.20.1 +docutils==0.21.1 # via sphinx furo==2024.1.29 - # via -r docs/requirements.in -idna==3.6 +idna==3.7 # via requests imagesize==1.4.1 # via sphinx jinja2==3.1.3 # via sphinx -lxml==5.1.0 +lxml==5.2.1 # via sphinx-json-schema-spec markupsafe==2.1.5 # via jinja2 -packaging==23.2 +packaging==24.0 # via sphinx pyenchant==3.2.2 # via sphinxcontrib-spelling @@ -40,20 +35,17 @@ pygments==2.17.2 # pygments-github-lexers # sphinx pygments-github-lexers==0.0.5 - # via -r docs/requirements.in -file:.#egg=referencing - # via -r docs/requirements.in +referencing @ file:.#egg=referencing requests==2.31.0 # via sphinx -rpds-py==0.17.1 +rpds-py==0.18.0 # via referencing snowballstemmer==2.2.0 # via sphinx soupsieve==2.5 # via beautifulsoup4 -sphinx==7.2.6 +sphinx==7.3.7 # via - # -r docs/requirements.in # furo # sphinx-basic-ng # sphinx-copybutton @@ -63,9 +55,7 @@ sphinx==7.2.6 sphinx-basic-ng==1.0.0b2 # via furo sphinx-copybutton==0.5.2 - # via -r docs/requirements.in sphinx-json-schema-spec==2024.1.1 - # via -r docs/requirements.in sphinxcontrib-applehelp==1.0.8 # via sphinx sphinxcontrib-devhelp==1.0.6 @@ -79,10 +69,7 @@ sphinxcontrib-qthelp==1.0.7 sphinxcontrib-serializinghtml==1.1.10 # via sphinx sphinxcontrib-spelling==8.0.0 - # via -r docs/requirements.in sphinxext-opengraph==0.9.1 - # via -r docs/requirements.in url-py==0.10.0 - # via -r docs/requirements.in -urllib3==2.2.0 +urllib3==2.2.1 # via requests diff --git a/noxfile.py b/noxfile.py index daee639..098ef0d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -14,12 +14,13 @@ tests=ROOT / "test-requirements.txt", ) REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other - path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values() + (path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values() ] SUPPORTED = ["3.8", "3.9", "3.10", "pypy3.10", "3.11", "3.12"] LATEST = SUPPORTED[-1] +nox.options.default_venv_backend = "uv|virtualenv" nox.options.sessions = [] @@ -167,13 +168,13 @@ def requirements(session): You should commit the result afterwards. """ - session.install("pip-tools") - for each in REQUIREMENTS_IN: - session.run( - "pip-compile", - "--resolver", - "backtracking", - "--strip-extras", - "-U", - each.relative_to(ROOT), - ) + if session.venv_backend == "uv": + cmd = ["uv", "pip", "compile"] + else: + session.install("pip-tools") + cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"] + + for each, out in REQUIREMENTS_IN: + # otherwise output files end up with silly absolute path comments... + relative = each.relative_to(ROOT) + session.run(*cmd, "--upgrade", "--output-file", out, relative) diff --git a/test-requirements.txt b/test-requirements.txt index 15dc604..a755dd4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,26 +1,18 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile --strip-extras test-requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile --output-file test-requirements.txt test-requirements.in attrs==23.2.0 # via # pytest-subtests # referencing iniconfig==2.0.0 # via pytest -packaging==23.2 +packaging==24.0 # via pytest -pluggy==1.4.0 +pluggy==1.5.0 # via pytest -pytest==8.0.0 - # via - # -r test-requirements.in - # pytest-subtests -pytest-subtests==0.11.0 - # via -r test-requirements.in -file:.#egg=referencing - # via -r test-requirements.in -rpds-py==0.17.1 +pytest==8.1.1 + # via pytest-subtests +pytest-subtests==0.12.1 +referencing @ file:.#egg=referencing +rpds-py==0.18.0 # via referencing From 72a1d292ab9245e39652c5061a91d6e1c4d3cb3f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 22 Apr 2024 11:54:11 +0300 Subject: [PATCH 07/12] uv and minor workflow tweaks --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bca556..c490c57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: CI on: push: + branches-ignore: + - "wip*" tags: - "v*" pull_request: @@ -10,6 +12,7 @@ on: schedule: # Daily at 8:33 - cron: "33 8 * * *" + workflow_dispatch: env: PIP_DISABLE_PIP_VERSION_CHECK: "1" @@ -33,6 +36,7 @@ jobs: ci: needs: list runs-on: ubuntu-latest + strategy: fail-fast: false matrix: @@ -64,8 +68,11 @@ jobs: pypy3.10 allow-prereleases: true cache: pip + - name: Set up uv + uses: hynek/setup-cached-uv@v1 - name: Set up nox - uses: wntrblm/nox@2024.03.02 + uses: wntrblm/nox@2024.04.15 + - name: Run nox run: nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }} From 0b03af7d27c8eee814de64ac522b8c54cabbd2ba Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 22 Apr 2024 12:13:02 +0300 Subject: [PATCH 08/12] Try convincing RTD to use uv. Refs: readthedocs/readthedocs.org#11290 --- .readthedocs.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index e6ab173..8a04e5f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,13 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.12" + + jobs: + post_create_environment: + - pip install uv + post_install: + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install -r docs/requirements.txt sphinx: builder: dirhtml @@ -11,7 +17,3 @@ sphinx: fail_on_warning: true formats: all - -python: - install: - - requirements: docs/requirements.txt From ac76038253de0b2ad076e964a5a889662de5a12b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:16:01 +0000 Subject: [PATCH 09/12] Bump suite from `71c85d0` to `87851a6` Bumps [suite](https://github.com/python-jsonschema/referencing-suite) from `71c85d0` to `87851a6`. - [Commits](https://github.com/python-jsonschema/referencing-suite/compare/71c85d053a433f97e497a4436a024c7856b31d24...87851a6d49f7df2072ed84042b86162040ef1ad3) --- updated-dependencies: - dependency-name: suite dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- suite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite b/suite index 71c85d0..87851a6 160000 --- a/suite +++ b/suite @@ -1 +1 @@ -Subproject commit 71c85d053a433f97e497a4436a024c7856b31d24 +Subproject commit 87851a6d49f7df2072ed84042b86162040ef1ad3 From cc3dc134c41f21f2302bb538b9d9a85a1d8f2a6e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 22 Apr 2024 19:23:54 +0300 Subject: [PATCH 10/12] Run coverage with 3.12 --- .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 c490c57..a92900e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: noxenv: ${{ fromJson(needs.list.outputs.noxenvs) }} posargs: [""] include: - - noxenv: tests-3.11 + - noxenv: tests-3.12 posargs: coverage github steps: From 1782bd5d82c1ea91c97c8d3e86efae8be9252d95 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 24 Apr 2024 09:41:47 +0300 Subject: [PATCH 11/12] Update pre-commit hooks. --- .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 8780e82..a3acb3e 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.3.7" + rev: "v0.4.1" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 4b51260349b9413105361f215d709322d8212b59 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 24 Apr 2024 09:46:53 +0300 Subject: [PATCH 12/12] Make Registry.contents raise NoSuchResource when needed. Previously it was propagating the KeyError (which we already don't do elsewhere on other registry methods). --- docs/changes.rst | 5 +++++ referencing/_core.py | 4 +--- referencing/tests/test_core.py | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 9575f40..b2229a2 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -2,6 +2,11 @@ Changelog ========= +v0.35.0 +------- + +* Ensure that ``Registry.contents()`` also raises ``NoSuchResource`` exceptions for nonexistent resources, not ``KeyError`` (which is an implementation detail). + v0.34.0 ------- diff --git a/referencing/_core.py b/referencing/_core.py index e6da867..d4c74c6 100644 --- a/referencing/_core.py +++ b/referencing/_core.py @@ -477,9 +477,7 @@ def contents(self, uri: URI) -> D: """ Retrieve the (already crawled) contents identified by the given URI. """ - # Empty fragment URIs are equivalent to URIs without the fragment. - # TODO: Is this true for non JSON Schema resources? Probably not. - return self._resources[uri.rstrip("#")].contents + return self[uri].contents def crawl(self) -> Registry[D]: """ diff --git a/referencing/tests/test_core.py b/referencing/tests/test_core.py index f676a48..3669e81 100644 --- a/referencing/tests/test_core.py +++ b/referencing/tests/test_core.py @@ -188,6 +188,12 @@ def test_contents_strips_empty_fragments(self): == {"ID": uri + "#"} ) + def test_contents_nonexistent_resource(self): + registry = Registry() + with pytest.raises(exceptions.NoSuchResource) as e: + registry.contents("urn:example") + assert e.value == exceptions.NoSuchResource(ref="urn:example") + def test_crawled_anchor(self): resource = ID_AND_CHILDREN.create_resource({"anchors": {"foo": "bar"}}) registry = Registry().with_resource("urn:example", resource)