project updates

This commit is contained in:
John Lancaster
2026-02-21 10:11:04 -06:00
parent b23a331953
commit 81b7b2650f
5 changed files with 35 additions and 8 deletions

27
.pre-commit-config.yaml Normal file
View File

@@ -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

View File

@@ -53,7 +53,7 @@ select = [
"C4", # flake8-comprehensions "C4", # flake8-comprehensions
"SIM", # flake8-simplify "SIM", # flake8-simplify
] ]
ignore = [] ignore = ["UP046"]
[tool.ruff.lint.isort] [tool.ruff.lint.isort]
known-first-party = ["daglib"] known-first-party = ["daglib"]

View File

@@ -69,7 +69,7 @@ class DAG(Generic[T], MutableMapping[T, DAGSetView[T]]):
case _: case _:
self._succ[u] |= {vs} self._succ[u] |= {vs}
self._pred[vs] |= {u} self._pred[vs] |= {u}
def __delitem__(self, u: T) -> None: def __delitem__(self, u: T) -> None:
self.discard_node(u) self.discard_node(u)

View File

@@ -38,7 +38,7 @@ class DAGSetView(MutableSet[T]):
def __contains__(self, x: object) -> bool: def __contains__(self, x: object) -> bool:
return x in self._data return x in self._data
def __iter__(self) -> Iterator[T]: def __iter__(self) -> Iterator[T]:
return iter(self._data) return iter(self._data)

View File

@@ -46,6 +46,11 @@ class TestDAGSetBasicOps:
s = DAGSetView({1, 2, 3}) s = DAGSetView({1, 2, 3})
assert len(s) == 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: def test_contains(self) -> None:
s = DAGSetView({1, 2, 3}) s = DAGSetView({1, 2, 3})
assert 1 in s assert 1 in s
@@ -80,11 +85,6 @@ class TestDAGSetBasicOps:
with pytest.raises(KeyError): with pytest.raises(KeyError):
s.remove(99) 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: class TestDAGSetCallbacks:
"""Test callback mechanisms.""" """Test callback mechanisms."""