From 99dda74a9ee9128a317c8f831d022f8f7d8aa358 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Mon, 30 Nov 2026 22:28:12 +0100 Subject: [PATCH] Enable PL in `ruff` --- pyproject.toml | 6 ++++-- src/velofy/db/addresses_addresses.py | 4 ++-- src/velofy/db/utils/locations.py | 3 +++ src/velofy/forecasts/methods/arima.py | 2 +- src/velofy/forecasts/methods/decomposition.py | 2 +- src/velofy/forecasts/methods/ets.py | 2 +- tests/test_init_r.py | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aa90de3..39a2e36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -253,6 +253,8 @@ select = [ # "FURB", # Perflint => No performance anti-patterns # "PERF", + # Pylint => Fewer bugs and simpler code + # "PL", # flake8-use-pathlib => `pathlib` instead of `os` functions # "PTH", # pyupgrade => Modern syntax for the targeted Python version @@ -535,8 +537,8 @@ select = [ "ICN", # Perflint => No performance anti-patterns "PERF", - # Pylint's refactoring rules => simpler and smaller functions - "PLR", + # Pylint => Fewer bugs and simpler code + "PL", # flake8-use-pathlib => `pathlib` instead of `os` functions "PTH", # flake8-print => no `print()` diff --git a/src/velofy/db/addresses_addresses.py b/src/velofy/db/addresses_addresses.py index 1aeb4da..c36e878 100644 --- a/src/velofy/db/addresses_addresses.py +++ b/src/velofy/db/addresses_addresses.py @@ -147,9 +147,9 @@ class Path(meta.Base): paths = [] # We consider all 2-tuples of `Address`es. The symmetric graph is ... - for first, second in itertools.combinations(addresses, 2): + for pair in itertools.combinations(addresses, 2): # ... implicitly enforced by a precedence constraint for the `.id`s. - first, second = (first, second) if first.id < second.id else (second, first) + first, second = sorted(pair, key=lambda address: address.id) # If there is no `Path` object in the database ... path = ( diff --git a/src/velofy/db/utils/locations.py b/src/velofy/db/utils/locations.py index df7ef6b..7ccf31c 100644 --- a/src/velofy/db/utils/locations.py +++ b/src/velofy/db/utils/locations.py @@ -94,6 +94,9 @@ class Location: """The UTM zone of the location as the zone number and the band.""" return self._zone, self._band + # Explicitly unhashable, the default for classes defining only `__eq__()` + __hash__ = None # type: ignore[assignment] + def __eq__(self, other: object) -> bool: """Check if two `Location` objects are the same location.""" if not isinstance(other, Location): diff --git a/src/velofy/forecasts/methods/arima.py b/src/velofy/forecasts/methods/arima.py index 4d916ac..562e3d6 100644 --- a/src/velofy/forecasts/methods/arima.py +++ b/src/velofy/forecasts/methods/arima.py @@ -33,7 +33,7 @@ def predict( """ # Initialize R only if it is actually used. # For example, the nox session "ci-tests-fast" does not use it. - from velofy import init_r # noqa:F401 + from velofy import init_r # noqa:F401,PLC0415 # Re-seed R every time it is used to ensure reproducibility. robjects.r("set.seed(42)") diff --git a/src/velofy/forecasts/methods/decomposition.py b/src/velofy/forecasts/methods/decomposition.py index 5a0a771..ca08ee3 100644 --- a/src/velofy/forecasts/methods/decomposition.py +++ b/src/velofy/forecasts/methods/decomposition.py @@ -153,7 +153,7 @@ def stl( # noqa:C901,PLR0912,PLR0913,PLR0915 # Initialize R only if it is actually used. # For example, the nox session "ci-tests-fast" does not use it. - from velofy import init_r # noqa:F401 + from velofy import init_r # noqa:F401,PLC0415 # Re-seed R every time it is used to ensure reproducibility. robjects.r("set.seed(42)") diff --git a/src/velofy/forecasts/methods/ets.py b/src/velofy/forecasts/methods/ets.py index ce404bc..7098f9d 100644 --- a/src/velofy/forecasts/methods/ets.py +++ b/src/velofy/forecasts/methods/ets.py @@ -34,7 +34,7 @@ def predict( """ # Initialize R only if it is actually used. # For example, the nox session "ci-tests-fast" does not use it. - from velofy import init_r # noqa:F401 + from velofy import init_r # noqa:F401,PLC0415 # Re-seed R every time it is used to ensure reproducibility. robjects.r("set.seed(42)") diff --git a/tests/test_init_r.py b/tests/test_init_r.py index 7a6755a..ef493ab 100644 --- a/tests/test_init_r.py +++ b/tests/test_init_r.py @@ -14,6 +14,6 @@ def test_r_packages_installed(): in the "research/r_dependencies.ipynb" notebook or in the GitHub Actions CI. """ - from velofy import init_r + from velofy import init_r # noqa:PLC0415 assert init_r is not None