From 81b7b2650ffc897bbd7e267c975ba1c6e30c052c Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:11:04 -0600 Subject: [PATCH] project updates --- .pre-commit-config.yaml | 27 +++++++++++++++++++++++++++ pyproject.toml | 2 +- src/daglib/dag.py | 2 +- src/daglib/set.py | 2 +- tests/test_dagset.py | 10 +++++----- 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0d8d6fc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.13 + hooks: + - id: ruff-check + types_or: [ python, pyi ] + args: [--fix-only, --exit-non-zero-on-fix] + # - id: ruff-format + # types_or: [ python, pyi ] + - repo: https://github.com/codespell-project/codespell + # Configuration for codespell is in pyproject.toml + rev: v2.4.1 + hooks: + - id: codespell + additional_dependencies: + - tomli + - repo: https://github.com/astral-sh/uv-pre-commit + # uv version. + rev: 0.9.26 + hooks: + # Update the uv lockfile + - id: uv-lock diff --git a/pyproject.toml b/pyproject.toml index ecaf4ec..0ef1bd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ select = [ "C4", # flake8-comprehensions "SIM", # flake8-simplify ] -ignore = [] +ignore = ["UP046"] [tool.ruff.lint.isort] known-first-party = ["daglib"] diff --git a/src/daglib/dag.py b/src/daglib/dag.py index 10f05d1..0227808 100644 --- a/src/daglib/dag.py +++ b/src/daglib/dag.py @@ -69,7 +69,7 @@ class DAG(Generic[T], MutableMapping[T, DAGSetView[T]]): case _: self._succ[u] |= {vs} self._pred[vs] |= {u} - + def __delitem__(self, u: T) -> None: self.discard_node(u) diff --git a/src/daglib/set.py b/src/daglib/set.py index 0f01302..cdd74c8 100644 --- a/src/daglib/set.py +++ b/src/daglib/set.py @@ -38,7 +38,7 @@ class DAGSetView(MutableSet[T]): def __contains__(self, x: object) -> bool: return x in self._data - + def __iter__(self) -> Iterator[T]: return iter(self._data) diff --git a/tests/test_dagset.py b/tests/test_dagset.py index 89d0739..aeadb5b 100644 --- a/tests/test_dagset.py +++ b/tests/test_dagset.py @@ -46,6 +46,11 @@ class TestDAGSetBasicOps: s = DAGSetView({1, 2, 3}) assert len(s) == 3 + def test_iter(self) -> None: + s = DAGSetView({1, 2, 3}) + for i, v in enumerate(s): + assert v == i + 1 + def test_contains(self) -> None: s = DAGSetView({1, 2, 3}) assert 1 in s @@ -80,11 +85,6 @@ class TestDAGSetBasicOps: with pytest.raises(KeyError): s.remove(99) - def test_iter(self) -> None: - s = DAGSetView({1, 2, 3}) - for i, v in enumerate(s): - assert v == i + 1 - class TestDAGSetCallbacks: """Test callback mechanisms."""