From f1ef70fc7e8a56fc80f2def6d2bab5f69c4fd9f5 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 13 Apr 2023 12:30:42 +0200 Subject: [PATCH 01/14] add ghcr backend for artifact info/ metadata --- .../artifact_info/info_json.py | 10 +- conda_forge_metadata/oci.py | 104 ++++++++++++++++++ pyproject.toml | 3 +- requirements.txt | 3 +- tests/test_info_json.py | 23 ++++ 5 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 conda_forge_metadata/oci.py create mode 100644 tests/test_info_json.py diff --git a/conda_forge_metadata/artifact_info/info_json.py b/conda_forge_metadata/artifact_info/info_json.py index ade2cbf..4f53b58 100644 --- a/conda_forge_metadata/artifact_info/info_json.py +++ b/conda_forge_metadata/artifact_info/info_json.py @@ -1,7 +1,8 @@ from conda_forge_metadata.libcfgraph import get_libcfgraph_artifact_data +from conda_forge_metadata.oci import get_oci_artifact_data -def get_artifact_info_as_json(channel, subdir, artifact): +def get_artifact_info_as_json(channel, subdir, artifact, backend="libcfgraph"): """Get a blob of artifact data from the conda info directory. Parameters @@ -35,4 +36,9 @@ def get_artifact_info_as_json(channel, subdir, artifact): "files": a list of files in the recipe from info/files with elements ending in .pyc or .txt filtered out. """ - return get_libcfgraph_artifact_data(channel, subdir, artifact) + if backend == "libcfgraph": + return get_libcfgraph_artifact_data(channel, subdir, artifact) + elif backend == "oci": + return get_oci_artifact_data(channel, subdir, artifact) + else: + raise ValueError(f"Unknown backend {backend!r}") diff --git a/conda_forge_metadata/oci.py b/conda_forge_metadata/oci.py new file mode 100644 index 0000000..373ac52 --- /dev/null +++ b/conda_forge_metadata/oci.py @@ -0,0 +1,104 @@ +from functools import lru_cache +from logging import getLogger + +import json + +from conda_oci_mirror.repo import PackageRepo +from ruamel import yaml + +logger = getLogger(__name__) + + +def _extract_read(infotar, *names) -> str | None: + names_in_tar = infotar.getnames() + for name in names: + if name in names_in_tar: + return infotar.extractfile(name).read().decode() + + +@lru_cache(maxsize=1024) +def get_oci_artifact_data( + channel: str, + subdir: str, + artifact: str, + registry: str = "ghcr.io/channel-mirrors", +) -> dict | None: + """Get a blob of artifact data from the conda info directory. + + Note this function might need token authentication to access the registry. + Export the following environment variables: + - ORAS_USER: the username to use for authentication + - ORAS_PASS: the password/token to use for authentication + + Parameters + ---------- + channel : str + The channel (e.g., "conda-forge"). + subdir : str + The subdir for the artifact (e.g., "noarch", "linux-64", etc.). + artifact : str + The full artifact name with extension (e.g., + "21cmfast-3.0.2-py36h13dd421_0.tar.bz2"). + registry : str + The registry to use for the OCI repository. + + Returns + ------- + info_blob : dict + A dictionary of data. Possible keys are + + "metadata_version": the metadata version format + "name": the package name + "version": the package version + "index": the info/index.json file contents + "about": the info/about.json file contents + "rendered_recipe": the fully rendered recipe at + either info/recipe/meta.yaml or info/meta.yaml + as a dict + "raw_recipe": the template recipe as a string from + info/recipe/meta.yaml.template - could be + the rendered recipe as a string if no template was found + "conda_build_config": the conda_build_config.yaml used for building + the recipe at info/recipe/conda_build_config.yaml + "files": a list of files in the recipe from info/files with + elements ending in .pyc or .txt filtered out. + + If the artifact is not indexed, it returns None. + """ + if artifact.endswith(".tar.bz2"): + artifact = artifact[: -len(".tar.bz2")] + elif artifact.endswith(".conda"): + artifact = artifact[: -len(".conda")] + else: + raise ValueError(f"Artifact '{artifact}' is not a conda package") + + repo = PackageRepo(channel, subdir, None, registry=registry) + + parts = artifact.rsplit("-", 2) + oci_name = f"{parts[0]}:{parts[1]}-{parts[2]}" + try: + infotar = repo.get_info(oci_name) + except ValueError as exc: + logger.debug("Failed to get info for %s", oci_name, exc_info=exc) + return None + + YAML = yaml.YAML(typ="safe") + + index = json.loads(_extract_read(infotar, "index.json")) + return { + # https://github.com/regro/libcflib/blob/062858e90af2795d2eb098034728cace574a51b8/libcflib/harvester.py#L14 + "metadata_version": 1, + "name": index.get("name", ""), + "version": index.get("version", ""), + "index": index, + "about": json.loads(_extract_read(infotar, "about.json")), + "rendered_recipe": YAML.load(_extract_read(infotar, "recipe/meta.yaml", "meta.yaml")), + "raw_recipe": _extract_read(infotar, "recipe/meta.yaml.template", "recipe/meta.yaml", "meta.yaml"), + "conda_build_config": YAML.load(_extract_read(infotar, "recipe/conda_build_config.yaml")), + "files": [f for f in _extract_read(infotar, "files").splitlines() if not f.lower().endswith((".pyc", ".txt"))] + } + +if __name__ == "__main__": + import sys + import pprint + pprint.pprint(get_oci_artifact_data(*sys.argv[1:])) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 42b8550..32872a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,8 @@ description = "programatic access to conda-forge's metadata" dynamic = ["version"] dependencies = [ "requests", - "pyyaml" + "ruamel.yaml", + "conda-oci-mirror@https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz" ] license = {file = "LICENSE"} readme = "README.md" diff --git a/requirements.txt b/requirements.txt index ae1f79e..ed2af7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ requests -pyyaml +ruamel.yaml +https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz diff --git a/tests/test_info_json.py b/tests/test_info_json.py new file mode 100644 index 0000000..6c5948a --- /dev/null +++ b/tests/test_info_json.py @@ -0,0 +1,23 @@ +import pytest + +from conda_forge_metadata.artifact_info import info_json + +@pytest.mark.parametrize("backend", ["libcfgraph", "oci"]) +def test_info_json(backend): + info = info_json.get_artifact_info_as_json( + "conda-forge", "osx-64", "21cmfast-3.0.2-py36h13dd421_0.tar.bz2", backend=backend, + ) + assert info["metadata_version"] == 1 + assert info["name"] == "21cmfast" + assert info["version"] == "3.0.2" + assert info["index"]["name"] == "21cmfast" + assert info["index"]["version"] == "3.0.2" + assert info["index"]["build"] == "py36h13dd421_0" + assert info["index"]["subdir"] == "osx-64" + assert "pyyaml" in info["index"]["depends"] + assert info["about"]["conda_version"] == "4.8.4" + assert info["rendered_recipe"]["package"]["name"] == "21cmfast" + assert info["rendered_recipe"]["source"]["sha256"] == "6e88960d134e98e4719343d853c63fc3c691438b57b2863f7834f07fae9eab4f" + assert info["raw_recipe"].startswith('{% set name = "21cmFAST" %}') + assert info["conda_build_config"]["CI"] == "azure" + assert "bin/21cmfast" in info["files"] From 399423eb847c8e323c34ad562884c53ee30a3bd9 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 13 Apr 2023 12:31:46 +0200 Subject: [PATCH 02/14] format --- conda_forge_metadata/oci.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/conda_forge_metadata/oci.py b/conda_forge_metadata/oci.py index 373ac52..63b1064 100644 --- a/conda_forge_metadata/oci.py +++ b/conda_forge_metadata/oci.py @@ -81,7 +81,7 @@ def get_oci_artifact_data( except ValueError as exc: logger.debug("Failed to get info for %s", oci_name, exc_info=exc) return None - + YAML = yaml.YAML(typ="safe") index = json.loads(_extract_read(infotar, "index.json")) @@ -92,13 +92,21 @@ def get_oci_artifact_data( "version": index.get("version", ""), "index": index, "about": json.loads(_extract_read(infotar, "about.json")), - "rendered_recipe": YAML.load(_extract_read(infotar, "recipe/meta.yaml", "meta.yaml")), - "raw_recipe": _extract_read(infotar, "recipe/meta.yaml.template", "recipe/meta.yaml", "meta.yaml"), - "conda_build_config": YAML.load(_extract_read(infotar, "recipe/conda_build_config.yaml")), - "files": [f for f in _extract_read(infotar, "files").splitlines() if not f.lower().endswith((".pyc", ".txt"))] + "rendered_recipe": YAML.load( + _extract_read(infotar, "recipe/meta.yaml", "meta.yaml") + ), + "raw_recipe": _extract_read( + infotar, + "recipe/meta.yaml.template", + "recipe/meta.yaml", + "meta.yaml", + ), + "conda_build_config": YAML.load( + _extract_read(infotar, "recipe/conda_build_config.yaml") + ), + "files": [ + f + for f in _extract_read(infotar, "files").splitlines() + if not f.lower().endswith((".pyc", ".txt")) + ], } - -if __name__ == "__main__": - import sys - import pprint - pprint.pprint(get_oci_artifact_data(*sys.argv[1:])) \ No newline at end of file From 02cdd1e5d8c3e105156666c47ef3f07b5efe3b03 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 13 Apr 2023 17:35:31 +0200 Subject: [PATCH 03/14] use ruamel here too --- conda_forge_metadata/autotick_bot/pypi_to_conda.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conda_forge_metadata/autotick_bot/pypi_to_conda.py b/conda_forge_metadata/autotick_bot/pypi_to_conda.py index c7a4e0f..224374a 100644 --- a/conda_forge_metadata/autotick_bot/pypi_to_conda.py +++ b/conda_forge_metadata/autotick_bot/pypi_to_conda.py @@ -1,6 +1,7 @@ from functools import lru_cache + import requests -import yaml +from ruamel import yaml @lru_cache(maxsize=1) @@ -10,7 +11,7 @@ def get_pypi_name_mapping(): "master/mappings/pypi/name_mapping.yaml" ) req.raise_for_status() - return yaml.safe_load(req.text) + return yaml.YAML(typ="safe").load(req.text) @lru_cache(maxsize=1) From 20a3ae26df689dde078f1ea62d5489b6a92147ef Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 13 Apr 2023 17:39:13 +0200 Subject: [PATCH 04/14] temporary workaround for conda-oci-mirror deps --- .github/workflows/tests.yml | 2 ++ requirements.txt | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4330523..f7d77ff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,6 +34,8 @@ jobs: mamba install --yes --file=requirements.txt mamba install --yes --file=requirements-dev.txt python -m pip install -v --no-deps --no-build-isolation -e . + # temporary + python -m pip install -v https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz --no-deps --no-build-isolation - name: test versions shell: bash -l {0} diff --git a/requirements.txt b/requirements.txt index ed2af7a..61b86f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,8 @@ requests ruamel.yaml -https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz +# https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz +# deps: +click +python-build +oras-py=0.1.14 +conda-package-handling From f7d9ab15e2c6e7fede7e500c833cf016171f4e34 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 13 Apr 2023 18:37:42 +0200 Subject: [PATCH 05/14] use Union instead of | --- conda_forge_metadata/oci.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conda_forge_metadata/oci.py b/conda_forge_metadata/oci.py index 63b1064..8ae6778 100644 --- a/conda_forge_metadata/oci.py +++ b/conda_forge_metadata/oci.py @@ -1,5 +1,6 @@ from functools import lru_cache from logging import getLogger +from typing import Union import json @@ -9,7 +10,7 @@ logger = getLogger(__name__) -def _extract_read(infotar, *names) -> str | None: +def _extract_read(infotar, *names) -> Union[str, None]: names_in_tar = infotar.getnames() for name in names: if name in names_in_tar: @@ -22,7 +23,7 @@ def get_oci_artifact_data( subdir: str, artifact: str, registry: str = "ghcr.io/channel-mirrors", -) -> dict | None: +) -> Union[dict, None]: """Get a blob of artifact data from the conda info directory. Note this function might need token authentication to access the registry. From 6148186d2ec674f71c5adf5138a5d4cc24e192f7 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Fri, 21 Apr 2023 09:37:48 -0500 Subject: [PATCH 06/14] Update requirements.txt --- requirements.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 61b86f1..057b76e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,3 @@ requests ruamel.yaml -# https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz -# deps: -click -python-build -oras-py=0.1.14 -conda-package-handling +conda-oci-mirror From 00cd31cc1858a2a14170d6de930b983ff3176d56 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Fri, 21 Apr 2023 09:38:01 -0500 Subject: [PATCH 07/14] Update .github/workflows/tests.yml --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f7d77ff..4330523 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,8 +34,6 @@ jobs: mamba install --yes --file=requirements.txt mamba install --yes --file=requirements-dev.txt python -m pip install -v --no-deps --no-build-isolation -e . - # temporary - python -m pip install -v https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz --no-deps --no-build-isolation - name: test versions shell: bash -l {0} From 5fe55e714bee3a31c9cc9abb0a3c00298cc3ea3d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 18:26:12 +0200 Subject: [PATCH 08/14] Apply suggestions from code review Co-authored-by: Matthew R. Becker --- conda_forge_metadata/artifact_info/info_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_forge_metadata/artifact_info/info_json.py b/conda_forge_metadata/artifact_info/info_json.py index 4f53b58..c0f2b0d 100644 --- a/conda_forge_metadata/artifact_info/info_json.py +++ b/conda_forge_metadata/artifact_info/info_json.py @@ -1,5 +1,4 @@ from conda_forge_metadata.libcfgraph import get_libcfgraph_artifact_data -from conda_forge_metadata.oci import get_oci_artifact_data def get_artifact_info_as_json(channel, subdir, artifact, backend="libcfgraph"): @@ -39,6 +38,7 @@ def get_artifact_info_as_json(channel, subdir, artifact, backend="libcfgraph"): if backend == "libcfgraph": return get_libcfgraph_artifact_data(channel, subdir, artifact) elif backend == "oci": + from conda_forge_metadata.oci import get_oci_artifact_data return get_oci_artifact_data(channel, subdir, artifact) else: raise ValueError(f"Unknown backend {backend!r}") From 747f04fa69e41f459440fa41acc13f432e25e4c1 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 18:30:13 +0200 Subject: [PATCH 09/14] move to optional deps --- conda_forge_metadata/artifact_info/info_json.py | 1 + pyproject.toml | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/conda_forge_metadata/artifact_info/info_json.py b/conda_forge_metadata/artifact_info/info_json.py index c0f2b0d..aef2572 100644 --- a/conda_forge_metadata/artifact_info/info_json.py +++ b/conda_forge_metadata/artifact_info/info_json.py @@ -39,6 +39,7 @@ def get_artifact_info_as_json(channel, subdir, artifact, backend="libcfgraph"): return get_libcfgraph_artifact_data(channel, subdir, artifact) elif backend == "oci": from conda_forge_metadata.oci import get_oci_artifact_data + return get_oci_artifact_data(channel, subdir, artifact) else: raise ValueError(f"Unknown backend {backend!r}") diff --git a/pyproject.toml b/pyproject.toml index e971ef0..ea9125d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,12 +15,16 @@ description = "programatic access to conda-forge's metadata" dynamic = ["version"] dependencies = [ "requests", - "ruamel.yaml", - "conda-oci-mirror@https://github.com/channel-mirrors/conda-oci-mirror/archive/018eebd010725eaaf891fbf6cd8438fb1e638b48.tar.gz" + "ruamel.yaml" ] license = {file = "LICENSE"} readme = "README.md" +[project.optional-dependencies] +oci = [ + "conda-oci-mirror" +] + [project.urls] home = "https://github.com/regro/conda-forge-metadata" From 4e9fa5e2dea8ebbcf2caf471fd02f5e0e5ec7063 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 18:36:23 +0200 Subject: [PATCH 10/14] pre-commit --- conda_forge_metadata/oci.py | 8 +++----- requirements.txt | 2 +- tests/test_info_json.py | 11 +++++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/conda_forge_metadata/oci.py b/conda_forge_metadata/oci.py index 8ae6778..ddf6387 100644 --- a/conda_forge_metadata/oci.py +++ b/conda_forge_metadata/oci.py @@ -1,8 +1,6 @@ +import json from functools import lru_cache from logging import getLogger -from typing import Union - -import json from conda_oci_mirror.repo import PackageRepo from ruamel import yaml @@ -10,7 +8,7 @@ logger = getLogger(__name__) -def _extract_read(infotar, *names) -> Union[str, None]: +def _extract_read(infotar, *names) -> str | None: names_in_tar = infotar.getnames() for name in names: if name in names_in_tar: @@ -23,7 +21,7 @@ def get_oci_artifact_data( subdir: str, artifact: str, registry: str = "ghcr.io/channel-mirrors", -) -> Union[dict, None]: +) -> dict | None: """Get a blob of artifact data from the conda info directory. Note this function might need token authentication to access the registry. diff --git a/requirements.txt b/requirements.txt index 057b76e..3d7b6df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ +conda-oci-mirror requests ruamel.yaml -conda-oci-mirror diff --git a/tests/test_info_json.py b/tests/test_info_json.py index 6c5948a..eead188 100644 --- a/tests/test_info_json.py +++ b/tests/test_info_json.py @@ -2,10 +2,14 @@ from conda_forge_metadata.artifact_info import info_json + @pytest.mark.parametrize("backend", ["libcfgraph", "oci"]) def test_info_json(backend): info = info_json.get_artifact_info_as_json( - "conda-forge", "osx-64", "21cmfast-3.0.2-py36h13dd421_0.tar.bz2", backend=backend, + "conda-forge", + "osx-64", + "21cmfast-3.0.2-py36h13dd421_0.tar.bz2", + backend=backend, ) assert info["metadata_version"] == 1 assert info["name"] == "21cmfast" @@ -17,7 +21,10 @@ def test_info_json(backend): assert "pyyaml" in info["index"]["depends"] assert info["about"]["conda_version"] == "4.8.4" assert info["rendered_recipe"]["package"]["name"] == "21cmfast" - assert info["rendered_recipe"]["source"]["sha256"] == "6e88960d134e98e4719343d853c63fc3c691438b57b2863f7834f07fae9eab4f" + assert ( + info["rendered_recipe"]["source"]["sha256"] + == "6e88960d134e98e4719343d853c63fc3c691438b57b2863f7834f07fae9eab4f" + ) assert info["raw_recipe"].startswith('{% set name = "21cmFAST" %}') assert info["conda_build_config"]["CI"] == "azure" assert "bin/21cmfast" in info["files"] From e797b721885dabb5b520f2bb4a3f0f7d82423077 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 19:38:25 +0200 Subject: [PATCH 11/14] use git url --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ea9125d..eb0fbd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ readme = "README.md" [project.optional-dependencies] oci = [ - "conda-oci-mirror" + "conda-oci-mirror@git+https://github.com/channel-mirrors/conda-oci-mirror.git@v0.1.0#egg=conda-oci-mirror" ] [project.urls] From b11796c71115f456366d222bb9cf2237ceae3550 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 19:39:03 +0200 Subject: [PATCH 12/14] use bash -e and single mamba command --- .github/workflows/tests.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 57ecb6f..bead3f7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,14 +29,15 @@ jobs: use-mamba: true - name: configure conda and install code - shell: bash -l {0} + shell: bash -el {0} run: | - mamba install --yes --file=requirements.txt - mamba install --yes --file=requirements-dev.txt + mamba install --yes \ + --file=requirements.txt \ + --file=requirements-dev.txt python -m pip install -v --no-deps --no-build-isolation -e . - name: test versions - shell: bash -l {0} + shell: bash -el {0} run: | pip uninstall conda-forge-metadata --yes [[ $(python setup.py --version) != "0.0.0" ]] || exit 1 @@ -60,6 +61,6 @@ jobs: python -m pip install -v --no-deps --no-build-isolation -e . - name: test - shell: bash -l {0} + shell: bash -el {0} run: | pytest -vvs tests From c29317ff8b30acaa7e6a2ae917ab46b07e172bd1 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 20:20:34 +0200 Subject: [PATCH 13/14] undo typing pyupgrades --- .pre-commit-config.yaml | 2 +- conda_forge_metadata/oci.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0931baa..7c245b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: rev: v2.32.0 hooks: - id: pyupgrade - args: ["--py310-plus", "--keep-runtime-typing"] + args: ["--py38-plus", "--keep-runtime-typing"] # Organize imports. - repo: https://github.com/pre-commit/mirrors-isort diff --git a/conda_forge_metadata/oci.py b/conda_forge_metadata/oci.py index ddf6387..3eaa9b1 100644 --- a/conda_forge_metadata/oci.py +++ b/conda_forge_metadata/oci.py @@ -1,6 +1,7 @@ import json from functools import lru_cache from logging import getLogger +from typing import Union from conda_oci_mirror.repo import PackageRepo from ruamel import yaml @@ -8,7 +9,7 @@ logger = getLogger(__name__) -def _extract_read(infotar, *names) -> str | None: +def _extract_read(infotar, *names) -> Union[str, None]: names_in_tar = infotar.getnames() for name in names: if name in names_in_tar: From 261565be60edcf15a336ba06caf551aa3429f576 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 21 Apr 2023 20:22:53 +0200 Subject: [PATCH 14/14] more unions --- conda_forge_metadata/oci.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_forge_metadata/oci.py b/conda_forge_metadata/oci.py index 3eaa9b1..8a43c9f 100644 --- a/conda_forge_metadata/oci.py +++ b/conda_forge_metadata/oci.py @@ -22,7 +22,7 @@ def get_oci_artifact_data( subdir: str, artifact: str, registry: str = "ghcr.io/channel-mirrors", -) -> dict | None: +) -> Union[dict, None]: """Get a blob of artifact data from the conda info directory. Note this function might need token authentication to access the registry.