From a24db98262aa3a5546347e1f6a9ea976237d5234 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Sat, 28 Nov 2026 04:57:25 +0100 Subject: [PATCH] Enable PLR in `ruff` --- pyproject.toml | 7 ++++++- src/velofy/db/addresses_addresses.py | 2 +- src/velofy/db/customers.py | 2 +- src/velofy/db/pixels.py | 2 +- src/velofy/forecasts/methods/decomposition.py | 2 +- tests/db/utils/test_locations.py | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 93de9f7..aa013c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -482,6 +482,8 @@ select = [ "ERA", # isort => imports are sorted "I", + # Pylint's refactoring rules => simpler and smaller functions + "PLR", # flake8-print => no `print()` "T20", ] @@ -489,6 +491,8 @@ select = [ extend-ignore = [ # Let the formatter handle trailing commas. "COM812", + # Thresholds like the ones in the maps read better as literals. + "PLR2004", # Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`. "PT023", # TODOs need neither an author nor an issue. @@ -511,9 +515,10 @@ extend-ignore = [ "scripts/**" = ["T20"] # - ANN0, ANN2 => Type annotations are not strictly enforced. # - D106 => The `Meta` class inside the factory_boy models do not need a docstring. +# - PLR0913, PLR0917 => `pytest` passes fixtures as arguments. # - S101 => `assert` statements are ok in the test suite. # - S311 => The `random` module is not used for cryptography. -"tests/**/*.py" = ["ANN0", "ANN2", "D106", "S101", "S311"] +"tests/**/*.py" = ["ANN0", "ANN2", "D106", "PLR0913", "PLR0917", "S101", "S311"] [tool.ruff.lint.flake8-pytest-style] # aligned with [tool.flake8] above diff --git a/src/velofy/db/addresses_addresses.py b/src/velofy/db/addresses_addresses.py index 5bb2c6e..ef965ab 100644 --- a/src/velofy/db/addresses_addresses.py +++ b/src/velofy/db/addresses_addresses.py @@ -254,7 +254,7 @@ class Path(meta.Base): return points - def draw( + def draw( # noqa:PLR0913 self, *, reverse: bool = False, diff --git a/src/velofy/db/customers.py b/src/velofy/db/customers.py index 69b6ee0..4aa0328 100644 --- a/src/velofy/db/customers.py +++ b/src/velofy/db/customers.py @@ -40,7 +40,7 @@ class Customer(meta.Base): """Shortcut to the `...city.map` object.""" return self.orders[0].pickup_address.city.map - def draw( # noqa:C901 + def draw( # noqa:C901,PLR0912 self, restaurants: bool = True, order_counts: bool = False, # pragma: no cover diff --git a/src/velofy/db/pixels.py b/src/velofy/db/pixels.py index 3146539..10b1901 100644 --- a/src/velofy/db/pixels.py +++ b/src/velofy/db/pixels.py @@ -141,7 +141,7 @@ class Pixel(meta.Base): """Shortcut to the `.city.map` object.""" return self.grid.city.map - def draw( # noqa:C901 + def draw( # noqa:C901,PLR0912 self, restaurants: bool = True, order_counts: bool = False, # pragma: no cover diff --git a/src/velofy/forecasts/methods/decomposition.py b/src/velofy/forecasts/methods/decomposition.py index 3104667..5d5d827 100644 --- a/src/velofy/forecasts/methods/decomposition.py +++ b/src/velofy/forecasts/methods/decomposition.py @@ -12,7 +12,7 @@ from rpy2 import robjects from rpy2.robjects import pandas2ri -def stl( # noqa:C901 +def stl( # noqa:C901,PLR0912,PLR0913,PLR0915 time_series: pd.Series, *, frequency: int, diff --git a/tests/db/utils/test_locations.py b/tests/db/utils/test_locations.py index 76bae4e..193ed41 100644 --- a/tests/db/utils/test_locations.py +++ b/tests/db/utils/test_locations.py @@ -98,7 +98,7 @@ class TestSpecialMethods: def test_compare_utm_coordinates_to_themselves(self, location): """Test `Location.__eq__()`.""" - result = location == location + result = location == location # noqa:PLR0124 assert result is True