From 7c389d1e18e7206e5d71fbc562c7c5b1af344392 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:13:03 +0100 Subject: [PATCH 01/11] ci: add dependabot action --- .github/workflows/dependabot.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/workflows/dependabot.yaml diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml new file mode 100644 index 0000000..570c103 --- /dev/null +++ b/.github/workflows/dependabot.yaml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From b6a50f27e04f1600c82c8dee13672fb7a0419ca4 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:14:12 +0100 Subject: [PATCH 02/11] ci: add gitlint action --- .github/workflows/gitlint.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/gitlint.yaml diff --git a/.github/workflows/gitlint.yaml b/.github/workflows/gitlint.yaml new file mode 100644 index 0000000..d397625 --- /dev/null +++ b/.github/workflows/gitlint.yaml @@ -0,0 +1,9 @@ +name: Run commit message linter +on: + pull_request: + +jobs: + gitlint: + uses: acdh-oeaw/prosnet-workflows/.github/workflows/gitlint.yml@v0.3.4 + with: + comment: false From 3269428355302335f2eafb9cdfdc4a771bc89b09 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:15:05 +0100 Subject: [PATCH 03/11] ci: add deptry action --- .github/workflows/deptry.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/deptry.yaml diff --git a/.github/workflows/deptry.yaml b/.github/workflows/deptry.yaml new file mode 100644 index 0000000..3038ce4 --- /dev/null +++ b/.github/workflows/deptry.yaml @@ -0,0 +1,22 @@ +name: Run deptry dependency checker + +on: [push, pull_request] + +jobs: + run-deptry: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Install dependencies + run: uv sync --dev + + - name: Run deptry + run: uv run deptry . From 7ceda67c996092266b6b8b01b0f51af8be9a787e Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:16:03 +0100 Subject: [PATCH 04/11] ci: add ruff linter action --- .github/workflows/ruff-linter.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ruff-linter.yaml diff --git a/.github/workflows/ruff-linter.yaml b/.github/workflows/ruff-linter.yaml new file mode 100644 index 0000000..0fbeb96 --- /dev/null +++ b/.github/workflows/ruff-linter.yaml @@ -0,0 +1,22 @@ +name: Run ruff linter + +on: [push, pull_request] + +jobs: + run-ruff-linter: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Install dependencies + run: uv sync --dev + + - name: Run ruff + run: uv run ruff check . From d74ad1d12c325e28593d55704fe553ccee0d2db5 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:16:10 +0100 Subject: [PATCH 05/11] ci: add ruff formatter action --- .github/workflows/ruff-formater.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ruff-formater.yaml diff --git a/.github/workflows/ruff-formater.yaml b/.github/workflows/ruff-formater.yaml new file mode 100644 index 0000000..3eaf458 --- /dev/null +++ b/.github/workflows/ruff-formater.yaml @@ -0,0 +1,23 @@ +name: Run ruff formatter + +on: [push, pull_request] + + +jobs: + run-ruff-format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Install dependencies + run: uv sync --dev + + - name: Run ruff + run: uv run ruff format --check . From 4f29a0b7aa3f25d3fc9f8c92f2ebade342aa43f8 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:18:47 +0100 Subject: [PATCH 06/11] chore(deps): install deptry and ruff as dev dependencies --- pyproject.toml | 2 ++ uv.lock | 66 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bd12b89..13c0134 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,8 @@ dev = [ "mkdocstrings[python]>=0.25.1,<0.26", "mkdocs-material>=9.5.27,<10", "pytest-randomly>=3.15.0,<4", + "ruff>=0.14.6", + "deptry>=0.24.0", ] [build-system] diff --git a/uv.lock b/uv.lock index c5b7d79..b4dcab4 100644 --- a/uv.lock +++ b/uv.lock @@ -91,6 +91,28 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d8/86/a12c544cfa2ba5265f3bafa15283fe9e99aa773db216b6da94085cb48529/coverage-7.5.3-cp312-cp312-win_amd64.whl", hash = "sha256:0bbddc54bbacfc09b3edaec644d4ac90c08ee8ed4844b0f86227dcda2d428fcb", size = 207598 }, ] +[[package]] +name = "deptry" +version = "0.24.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "packaging" }, + { name = "requirements-parser" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/58/aa/5cae0f25a2ac5334d5bd2782a6bcd80eecf184f433ff74b2fb0387cfbbb6/deptry-0.24.0.tar.gz", hash = "sha256:852e88af2087e03cdf9ece6916f3f58b74191ab51cc8074897951bd496ee7dbb", size = 440158 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/21/5a/c1552996499911b6eabe874a994d9eede58ac3936d7fe7f865857b97c03f/deptry-0.24.0-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:a575880146bab671a62babb9825b85b4f1bda8aeaade4fcb59f9262caf91d6c7", size = 1774138 }, + { url = "https://files.pythonhosted.org/packages/32/b6/1dcc011fc3e6eec71601569c9de3215530563412b3714fba80dcd1a88ec8/deptry-0.24.0-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:00ec34b968a13c03a5268ce0211f891ace31851d916415e0a748fae9596c00d5", size = 1677340 }, + { url = "https://files.pythonhosted.org/packages/4a/e2/af81dfd46b457be9e8ded9472872141777fbda8af661f5d509157b165359/deptry-0.24.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6ddfedafafe5cbfce31a50d4ea99d7b9074edcd08b9b94350dc739e2fb6ed7f9", size = 1782740 }, + { url = "https://files.pythonhosted.org/packages/ab/28/960c311aae084deef57ece41aac13cb359b06ce31b7771139e79c394a1b7/deptry-0.24.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd22fa2dbbdf4b38061ca9504f2a6ce41ec14fa5c9fe9b0b763ccc1275efebd5", size = 1845477 }, + { url = "https://files.pythonhosted.org/packages/f5/6c/4b972b011a06611e0cf8f4bb6bc04a3d0f9c651950ad9abe320fcbac6983/deptry-0.24.0-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:0fbe50a2122d79cec53fdfd73a7092c05f316555a1139bcbacf3432572675977", size = 1960410 }, + { url = "https://files.pythonhosted.org/packages/1b/08/0eac3c72a9fd79a043cc492f3ba350c47a7be2160288353218b2c8c1bf3a/deptry-0.24.0-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:92bd8d331a5a6f8e6247436bc6fe384bcf86a8d69fe33442d195996fb9b20547", size = 2023832 }, + { url = "https://files.pythonhosted.org/packages/35/e4/23dcbc505f6f35c70ba68015774cf891ceda080331d7fd6d75e84ada9f73/deptry-0.24.0-cp39-abi3-win_amd64.whl", hash = "sha256:94b354848130d45e16d3a3039ae8177bce33828f62028c4ff8f2e1b04f7182ba", size = 1631631 }, + { url = "https://files.pythonhosted.org/packages/39/69/6ec1e18e27dd6f80e4fb6c5fc05a6527242ff83b81c0711d0ba470e9a144/deptry-0.24.0-cp39-abi3-win_arm64.whl", hash = "sha256:ea58709e5f3aa77c0737d8fb76166b7703201cf368fbbb14072ccda968b6703a", size = 1550504 }, +] + [[package]] name = "ghp-import" version = "2.1.0" @@ -201,7 +223,7 @@ wheels = [ [[package]] name = "lodkit" -version = "0.2.9" +version = "0.3.0" source = { editable = "." } dependencies = [ { name = "hypothesis", extra = ["pytz"] }, @@ -214,6 +236,7 @@ dependencies = [ [package.dev-dependencies] dev = [ + { name = "deptry" }, { name = "mkdocs" }, { name = "mkdocs-material" }, { name = "mkdocstrings", extra = ["python"] }, @@ -221,6 +244,7 @@ dev = [ { name = "pytest-cov" }, { name = "pytest-loguru" }, { name = "pytest-randomly" }, + { name = "ruff" }, { name = "typeguard" }, ] @@ -236,6 +260,7 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ + { name = "deptry", specifier = ">=0.24.0" }, { name = "mkdocs", specifier = ">=1.6.0,<2" }, { name = "mkdocs-material", specifier = ">=9.5.27,<10" }, { name = "mkdocstrings", extras = ["python"], specifier = ">=0.25.1,<0.26" }, @@ -243,6 +268,7 @@ dev = [ { name = "pytest-cov", specifier = ">=5.0.0,<6" }, { name = "pytest-loguru", specifier = ">=0.4.0,<0.5" }, { name = "pytest-randomly", specifier = ">=3.15.0,<4" }, + { name = "ruff", specifier = ">=0.14.6" }, { name = "typeguard", specifier = ">=4.3.0,<5" }, ] @@ -661,6 +687,44 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6", size = 64928 }, ] +[[package]] +name = "requirements-parser" +version = "0.13.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/95/96/fb6dbfebb524d5601d359a47c78fe7ba1eef90fc4096404aa60c9a906fbb/requirements_parser-0.13.0.tar.gz", hash = "sha256:0843119ca2cb2331de4eb31b10d70462e39ace698fd660a915c247d2301a4418", size = 22630 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bd/60/50fbb6ffb35f733654466f1a90d162bcbea358adc3b0871339254fbc37b2/requirements_parser-0.13.0-py3-none-any.whl", hash = "sha256:2b3173faecf19ec5501971b7222d38f04cb45bb9d87d0ad629ca71e2e62ded14", size = 14782 }, +] + +[[package]] +name = "ruff" +version = "0.14.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/52/f0/62b5a1a723fe183650109407fa56abb433b00aa1c0b9ba555f9c4efec2c6/ruff-0.14.6.tar.gz", hash = "sha256:6f0c742ca6a7783a736b867a263b9a7a80a45ce9bee391eeda296895f1b4e1cc", size = 5669501 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/67/d2/7dd544116d107fffb24a0064d41a5d2ed1c9d6372d142f9ba108c8e39207/ruff-0.14.6-py3-none-linux_armv6l.whl", hash = "sha256:d724ac2f1c240dbd01a2ae98db5d1d9a5e1d9e96eba999d1c48e30062df578a3", size = 13326119 }, + { url = "https://files.pythonhosted.org/packages/36/6a/ad66d0a3315d6327ed6b01f759d83df3c4d5f86c30462121024361137b6a/ruff-0.14.6-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9f7539ea257aa4d07b7ce87aed580e485c40143f2473ff2f2b75aee003186004", size = 13526007 }, + { url = "https://files.pythonhosted.org/packages/a3/9d/dae6db96df28e0a15dea8e986ee393af70fc97fd57669808728080529c37/ruff-0.14.6-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7f6007e55b90a2a7e93083ba48a9f23c3158c433591c33ee2e99a49b889c6332", size = 12676572 }, + { url = "https://files.pythonhosted.org/packages/76/a4/f319e87759949062cfee1b26245048e92e2acce900ad3a909285f9db1859/ruff-0.14.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a8e7b9d73d8728b68f632aa8e824ef041d068d231d8dbc7808532d3629a6bef", size = 13140745 }, + { url = "https://files.pythonhosted.org/packages/95/d3/248c1efc71a0a8ed4e8e10b4b2266845d7dfc7a0ab64354afe049eaa1310/ruff-0.14.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d50d45d4553a3ebcbd33e7c5e0fe6ca4aafd9a9122492de357205c2c48f00775", size = 13076486 }, + { url = "https://files.pythonhosted.org/packages/a5/19/b68d4563fe50eba4b8c92aa842149bb56dd24d198389c0ed12e7faff4f7d/ruff-0.14.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:118548dd121f8a21bfa8ab2c5b80e5b4aed67ead4b7567790962554f38e598ce", size = 13727563 }, + { url = "https://files.pythonhosted.org/packages/47/ac/943169436832d4b0e867235abbdb57ce3a82367b47e0280fa7b4eabb7593/ruff-0.14.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:57256efafbfefcb8748df9d1d766062f62b20150691021f8ab79e2d919f7c11f", size = 15199755 }, + { url = "https://files.pythonhosted.org/packages/c9/b9/288bb2399860a36d4bb0541cb66cce3c0f4156aaff009dc8499be0c24bf2/ruff-0.14.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ff18134841e5c68f8e5df1999a64429a02d5549036b394fafbe410f886e1989d", size = 14850608 }, + { url = "https://files.pythonhosted.org/packages/ee/b1/a0d549dd4364e240f37e7d2907e97ee80587480d98c7799d2d8dc7a2f605/ruff-0.14.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:29c4b7ec1e66a105d5c27bd57fa93203637d66a26d10ca9809dc7fc18ec58440", size = 14118754 }, + { url = "https://files.pythonhosted.org/packages/13/ac/9b9fe63716af8bdfddfacd0882bc1586f29985d3b988b3c62ddce2e202c3/ruff-0.14.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:167843a6f78680746d7e226f255d920aeed5e4ad9c03258094a2d49d3028b105", size = 13949214 }, + { url = "https://files.pythonhosted.org/packages/12/27/4dad6c6a77fede9560b7df6802b1b697e97e49ceabe1f12baf3ea20862e9/ruff-0.14.6-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:16a33af621c9c523b1ae006b1b99b159bf5ac7e4b1f20b85b2572455018e0821", size = 14106112 }, + { url = "https://files.pythonhosted.org/packages/6a/db/23e322d7177873eaedea59a7932ca5084ec5b7e20cb30f341ab594130a71/ruff-0.14.6-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1432ab6e1ae2dc565a7eea707d3b03a0c234ef401482a6f1621bc1f427c2ff55", size = 13035010 }, + { url = "https://files.pythonhosted.org/packages/a8/9c/20e21d4d69dbb35e6a1df7691e02f363423658a20a2afacf2a2c011800dc/ruff-0.14.6-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:4c55cfbbe7abb61eb914bfd20683d14cdfb38a6d56c6c66efa55ec6570ee4e71", size = 13054082 }, + { url = "https://files.pythonhosted.org/packages/66/25/906ee6a0464c3125c8d673c589771a974965c2be1a1e28b5c3b96cb6ef88/ruff-0.14.6-py3-none-musllinux_1_2_i686.whl", hash = "sha256:efea3c0f21901a685fff4befda6d61a1bf4cb43de16da87e8226a281d614350b", size = 13303354 }, + { url = "https://files.pythonhosted.org/packages/4c/58/60577569e198d56922b7ead07b465f559002b7b11d53f40937e95067ca1c/ruff-0.14.6-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:344d97172576d75dc6afc0e9243376dbe1668559c72de1864439c4fc95f78185", size = 14054487 }, + { url = "https://files.pythonhosted.org/packages/67/0b/8e4e0639e4cc12547f41cb771b0b44ec8225b6b6a93393176d75fe6f7d40/ruff-0.14.6-py3-none-win32.whl", hash = "sha256:00169c0c8b85396516fdd9ce3446c7ca20c2a8f90a77aa945ba6b8f2bfe99e85", size = 13013361 }, + { url = "https://files.pythonhosted.org/packages/fb/02/82240553b77fd1341f80ebb3eaae43ba011c7a91b4224a9f317d8e6591af/ruff-0.14.6-py3-none-win_amd64.whl", hash = "sha256:390e6480c5e3659f8a4c8d6a0373027820419ac14fa0d2713bd8e6c3e125b8b9", size = 14432087 }, + { url = "https://files.pythonhosted.org/packages/a5/1f/93f9b0fad9470e4c829a5bb678da4012f0c710d09331b860ee555216f4ea/ruff-0.14.6-py3-none-win_arm64.whl", hash = "sha256:d43c81fbeae52cfa8728d8766bbf46ee4298c888072105815b392da70ca836b2", size = 13520930 }, +] + [[package]] name = "setuptools" version = "70.1.1" From f64285ec2e39602ea9d6ddc3ce80100dbe6d6e8a Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 10:23:11 +0100 Subject: [PATCH 07/11] chore: remove pytz and loguru fixture The change removes pytz as a dependency and also conftest.py which defined a loguru fixture; the code base now passes deptry. --- conftest.py | 19 ------------------- pyproject.toml | 1 - uv.lock | 2 -- 3 files changed, 22 deletions(-) delete mode 100644 conftest.py diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 7356464..0000000 --- a/conftest.py +++ /dev/null @@ -1,19 +0,0 @@ -"""Pytest conftest file for fixtures and hook functions.""" - -from _pytest.logging import LogCaptureFixture -from loguru import logger -import pytest - - -@pytest.fixture -def caplog(caplog: LogCaptureFixture): - """Enable the caplog fixture for loguru.""" - handler_id = logger.add( - caplog.handler, - format="{message}", - level=0, - filter=lambda record: record["level"].no >= caplog.handler.level, - enqueue=False, # Set to 'True' if your test is spawning child processes. - ) - yield caplog - logger.remove(handler_id) diff --git a/pyproject.toml b/pyproject.toml index 13c0134..a114a3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,6 @@ dependencies = [ "rdflib>=7.0.0,<8", "langcodes>=3.4.0,<4", "typeguard>=4.3.0,<5", - "pytz~=2024.2", "hypothesis[pytz]>=6.112.2,<7", ] diff --git a/uv.lock b/uv.lock index b4dcab4..95a1d36 100644 --- a/uv.lock +++ b/uv.lock @@ -229,7 +229,6 @@ dependencies = [ { name = "hypothesis", extra = ["pytz"] }, { name = "langcodes" }, { name = "loguru" }, - { name = "pytz" }, { name = "rdflib" }, { name = "typeguard" }, ] @@ -253,7 +252,6 @@ requires-dist = [ { name = "hypothesis", extras = ["pytz"], specifier = ">=6.112.2,<7" }, { name = "langcodes", specifier = ">=3.4.0,<4" }, { name = "loguru", specifier = ">=0.7.2,<0.8" }, - { name = "pytz", specifier = "~=2024.2" }, { name = "rdflib", specifier = ">=7.0.0,<8" }, { name = "typeguard", specifier = ">=4.3.0,<5" }, ] From 71507f1c201ed745927fa8cfd3893242ad2a9fca Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 16:46:42 +0100 Subject: [PATCH 08/11] chore: add F401 ignore for __init__.py files --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index a114a3d..19c695d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,3 +44,6 @@ markers = [ "remote: Indicate tests against actual remote sources.", "slow: Indicate tests which are known to be slow." ] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] \ No newline at end of file From 024d7a3c52971080cc14b76f8f1d9ae3e6540774 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 17:04:52 +0100 Subject: [PATCH 09/11] chore: multiple modifications to make ruff checks pass The entire test suite is in the process of being rewritten, so this is merely to make the ruff checks pass for now. --- lodkit/triple_tools/ttl_constructor.py | 1 - tests/data/fail_triples.py | 2 +- .../test_closed_ontology_namespace.py | 8 +++----- .../test_namespacegraph.py | 7 +++---- tests/test_uri_tools/test_uribase.py | 19 ++----------------- tests/test_uri_tools/test_uriclass.py | 2 +- tests/utils/strategies/__init__.py | 4 ++-- 7 files changed, 12 insertions(+), 31 deletions(-) diff --git a/lodkit/triple_tools/ttl_constructor.py b/lodkit/triple_tools/ttl_constructor.py index 7f0eb23..6660cdd 100644 --- a/lodkit/triple_tools/ttl_constructor.py +++ b/lodkit/triple_tools/ttl_constructor.py @@ -1,7 +1,6 @@ """LODKit Triple utilities.""" from collections.abc import Iterable, Iterator -from itertools import repeat from lodkit.lod_types import _Triple, _TripleObject, _TripleSubject from rdflib import BNode, Graph, Literal, RDF, URIRef diff --git a/tests/data/fail_triples.py b/tests/data/fail_triples.py index 78dbe5c..2864adb 100644 --- a/tests/data/fail_triples.py +++ b/tests/data/fail_triples.py @@ -8,7 +8,7 @@ s = URIRef("https://test.org/test_subject") p = URIRef("https://test.org/test_predicate") o = URIRef("https://test.org/test_object") -l = Literal("test_literal") +l = Literal("test_literal") # noqa: E741 b = BNode() diff --git a/tests/test_namespace_tools/test_closed_ontology_namespace.py b/tests/test_namespace_tools/test_closed_ontology_namespace.py index 534c55b..a02393d 100644 --- a/tests/test_namespace_tools/test_closed_ontology_namespace.py +++ b/tests/test_namespace_tools/test_closed_ontology_namespace.py @@ -63,9 +63,7 @@ def test_closed_ontology_namespace_delimiter_side_effects_exception(fail_ontolog """Check if an undelimited namespace raises an exception if strict_delimiters=True.""" with pytest.raises(NamespaceDelimiterException): - closed_ontology_namespace = ClosedOntologyNamespace( - fail_ontology, strict_delimiters=True - ) + ClosedOntologyNamespace(fail_ontology, strict_delimiters=True) @parametrize_paths_from_glob( @@ -90,11 +88,11 @@ def test_closed_ontology_multi_header_fail(): """Check if a MultiOntologyHeadersException is raised.""" fail_ontology_path = fail_ontologies_path / "header_fails/multiple_headers.ttl" with pytest.raises(MultiOntologyHeadersException): - closed_ontology_namespace = ClosedOntologyNamespace(fail_ontology_path) + ClosedOntologyNamespace(fail_ontology_path) def test_closed_ontology_no_header_fail(): """Check if a NoOntologyHeadersException is raised.""" fail_ontology_path = fail_ontologies_path / "header_fails/no_header_cidoc.ttl" with pytest.raises(NoOntologyHeaderException): - closed_ontology_namespace = ClosedOntologyNamespace(fail_ontology_path) + ClosedOntologyNamespace(fail_ontology_path) diff --git a/tests/test_namespace_tools/test_namespacegraph.py b/tests/test_namespace_tools/test_namespacegraph.py index 700bcea..67916d6 100644 --- a/tests/test_namespace_tools/test_namespacegraph.py +++ b/tests/test_namespace_tools/test_namespacegraph.py @@ -2,11 +2,9 @@ from types import new_class -import pytest -from typeguard import TypeCheckError - from hypothesis import given from lodkit import NamespaceGraph +import pytest from rdflib import URIRef from tests.utils.strategies import ( fail_pairs, @@ -14,6 +12,7 @@ name_uri_pairs, name_uriref_pairs, ) +from typeguard import TypeCheckError def _namespacegraph_containment_helper(assignment_pair: tuple[str, str]): @@ -54,7 +53,7 @@ def test_fail_on_value(pair): """Check if type-invalid inputs cause a TypeCheckError.""" with pytest.raises(TypeCheckError): name, namespace = pair - NamespaceGraphCls = new_class( + new_class( "NamespaceGraphCls", bases=(NamespaceGraph,), exec_body=lambda ns: ns.update({name: namespace}), diff --git a/tests/test_uri_tools/test_uribase.py b/tests/test_uri_tools/test_uribase.py index 4b77796..69ac500 100644 --- a/tests/test_uri_tools/test_uribase.py +++ b/tests/test_uri_tools/test_uribase.py @@ -6,25 +6,10 @@ from lodkit import mkuri_factory, uribase from lodkit.uri_tools.uribase import InstantiationException import pytest -from rdflib import Namespace, URIRef +from rdflib import Namespace from tests.utils.strategies.ns_strategies import public_variable_names -@given(public_variable_names) -def test_uribase_uuids(variable_name): - """Check if a uribase base class constructs UUID URIs for 'loose' class attributes. - - Note: This is awkward to test and awkward to use and probably not a good idea anyways. - """ - uribase_code: str = f"""class uribase_cls(uribase(Namespace('https://lodkit.testing/'))): - {variable_name}""" - - exec(uribase_code, globals()) - uri = getattr(uribase_cls, variable_name) - - assert isinstance(uri, URIRef) - - @given(public_variable_names, st.text()) def test_uribase_hashed(variable_name, hash_value): """Check if uribase and mkuri_factory constructed hashed URIs are equal.""" @@ -44,7 +29,7 @@ def test_uribase_hashed(variable_name, hash_value): def test_uribase_instantiation_fail(variable_name, hash_value): """Check if uribase and mkuri_factory constructed hashed URIs are equal.""" namespace = Namespace("https://lodkit.testing/") - mkuri = mkuri_factory(namespace) + mkuri_factory(namespace) uribase_cls = new_class( "uribase_cls", diff --git a/tests/test_uri_tools/test_uriclass.py b/tests/test_uri_tools/test_uriclass.py index 482980e..fa8214f 100644 --- a/tests/test_uri_tools/test_uriclass.py +++ b/tests/test_uri_tools/test_uriclass.py @@ -68,4 +68,4 @@ def test_make_uriclass_generate_pairs_type_fail(x, y): """Simple case for triggering a TyperError in make_uriclass.""" with pytest.raises(TypeError): namespace = Namespace("https://lodkit.testing/") - uricls = make_uriclass("uricls", namespace, fields=((x, y),)) + make_uriclass("uricls", namespace, fields=((x, y),)) diff --git a/tests/utils/strategies/__init__.py b/tests/utils/strategies/__init__.py index 42e151e..81acb8e 100644 --- a/tests/utils/strategies/__init__.py +++ b/tests/utils/strategies/__init__.py @@ -1,2 +1,2 @@ -from tests.utils.strategies.ns_strategies import * -from tests.utils.strategies.ttl_strategies import * +from tests.utils.strategies.ns_strategies import * # noqa: F403, F405 +from tests.utils.strategies.ttl_strategies import * # noqa: F403, F405 From 9481f642fe9baeb5a62ad7d37d8ffa07caa2dcd5 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 17:07:21 +0100 Subject: [PATCH 10/11] chore: run ruff formatter --- lodkit/namespace_tools/utils.py | 4 +--- tests/utils/strategies/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lodkit/namespace_tools/utils.py b/lodkit/namespace_tools/utils.py index 64e17c6..f13f8f9 100644 --- a/lodkit/namespace_tools/utils.py +++ b/lodkit/namespace_tools/utils.py @@ -26,9 +26,7 @@ """Source parameter type for rdflib.Graph.parse. This is the exact type defined in RDFLib. """, -] = ( - IO[bytes] | TextIO | InputSource | str | bytes | PurePath -) +] = IO[bytes] | TextIO | InputSource | str | bytes | PurePath def _get_ontology_graph(ontology_reference: Graph | _TGraphParseSource) -> Graph: # type: ignore diff --git a/tests/utils/strategies/__init__.py b/tests/utils/strategies/__init__.py index 81acb8e..8401a0a 100644 --- a/tests/utils/strategies/__init__.py +++ b/tests/utils/strategies/__init__.py @@ -1,2 +1,2 @@ -from tests.utils.strategies.ns_strategies import * # noqa: F403, F405 -from tests.utils.strategies.ttl_strategies import * # noqa: F403, F405 +from tests.utils.strategies.ns_strategies import * # noqa: F403, F405 +from tests.utils.strategies.ttl_strategies import * # noqa: F403, F405 From 0e8d2ddbf3e8ab28dfb268562d6e98a4a34b842d Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Fri, 28 Nov 2025 17:14:46 +0100 Subject: [PATCH 11/11] ci: add simple gitlint action --- .github/workflows/gitlint.yaml | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gitlint.yaml b/.github/workflows/gitlint.yaml index d397625..ad5dd1d 100644 --- a/.github/workflows/gitlint.yaml +++ b/.github/workflows/gitlint.yaml @@ -1,9 +1,53 @@ -name: Run commit message linter +name: Run gitlint + on: - pull_request: + workflow_call: + inputs: + ignore: + required: false + type: string + # B6: body-is-missing + # B5: body-min-length + default: "B6,B5" + contrib: + required: false + type: string + default: "contrib-title-conventional-commits" + basebranch: + required: false + type: string + default: "main" + arguments: + required: false + type: string + default: "-c body-max-line-length.line-length=120" + comment: + required: false + type: boolean + default: false jobs: gitlint: - uses: acdh-oeaw/prosnet-workflows/.github/workflows/gitlint.yml@v0.3.4 - with: - comment: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Extract branch name + run: echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV + - name: Install gitlint + run: sudo apt-get -y install gitlint + - name: Run gitlint + run: | + gitlint ${{inputs.arguments}} --fail-without-commits --contrib ${{inputs.contrib}} --ignore ${{inputs.ignore}} --commits origin/${{inputs.basebranch}}..origin/$GIT_BRANCH + id: gitlint + - uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Thanks for your contribution! ⚠️ there seems to be a problem with your commit messages - they should adhere to the [https://conventionalcommits.org](conventionalcommits) specification. Please fix that!' + }) + if: ${{ failure() && steps.gitlint.conclusion == 'failure' && inputs.comment }}