Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
22 changes: 22 additions & 0 deletions .github/workflows/deptry.yaml
Original file line number Diff line number Diff line change
@@ -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 .
53 changes: 53 additions & 0 deletions .github/workflows/gitlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run gitlint

on:
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:
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 }}
23 changes: 23 additions & 0 deletions .github/workflows/ruff-formater.yaml
Original file line number Diff line number Diff line change
@@ -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 .
22 changes: 22 additions & 0 deletions .github/workflows/ruff-linter.yaml
Original file line number Diff line number Diff line change
@@ -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 .
19 changes: 0 additions & 19 deletions conftest.py

This file was deleted.

4 changes: 1 addition & 3 deletions lodkit/namespace_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lodkit/triple_tools/ttl_constructor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand All @@ -24,6 +23,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]
Expand All @@ -43,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"]
2 changes: 1 addition & 1 deletion tests/data/fail_triples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
8 changes: 3 additions & 5 deletions tests/test_namespace_tools/test_closed_ontology_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
7 changes: 3 additions & 4 deletions tests/test_namespace_tools/test_namespacegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

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,
name_namespace_pairs,
name_uri_pairs,
name_uriref_pairs,
)
from typeguard import TypeCheckError


def _namespacegraph_containment_helper(assignment_pair: tuple[str, str]):
Expand Down Expand Up @@ -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}),
Expand Down
19 changes: 2 additions & 17 deletions tests/test_uri_tools/test_uribase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_uri_tools/test_uriclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),))
4 changes: 2 additions & 2 deletions tests/utils/strategies/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Loading