diff --git a/noxfile.py b/noxfile.py index 8c238f4..3943923 100644 --- a/noxfile.py +++ b/noxfile.py @@ -194,6 +194,7 @@ def lint_code(session: nox.Session) -> None: "flake8-annotations", "flake8-bandit", "flake8-black", + "flake8-boolean-trap", "flake8-broken-line", "flake8-bugbear", "flake8-builtins", diff --git a/pyproject.toml b/pyproject.toml index a73b259..d649a89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,6 +94,7 @@ dev = [ "flake8-annotations (>=3.3.1,<4.0.0)", "flake8-bandit (>=4.1.1,<5.0.0)", "flake8-black (>=0.5.0,<0.6.0)", + "flake8-boolean-trap (>=1.0.1,<2.0.0)", "flake8-broken-line (>=1.0.0,<2.0.0)", "flake8-bugbear (>=26.11.22,<27.0.0)", "flake8-builtins (>=3.2.0,<4.0.0)", @@ -210,6 +211,8 @@ select = [ "S1", "S2", "S3", "S4", "S5", "S6", "S7", # flake8-black => complain if black would make changes "BLK1", "BLK9", + # flake8-boolean-trap => Keyword-only flags + "FBT", # flake8-broken-line => no \ to end a line "N400", # flake8-bugbear => opinionated bugs and design flaws @@ -279,6 +282,8 @@ extend-ignore = [ # Comply with black's style. # Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8 "E203", "W503", + # `ruff`'s FBT003 does this better, as it allows builtins like `setattr()`. + "FBT003", # Every `.add()` looks like `pandas` to this rule (`ruff` omits it). "PD005", # Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`. @@ -506,6 +511,8 @@ select = [ "E", "W", # pyflakes => basic errors "F", + # flake8-boolean-trap => Keyword-only flags + "FBT", # flake8-implicit-str-concat => Unified string concatenation "ISC", # pep8-naming => PEP8 naming conventions diff --git a/src/velofy/console/main.py b/src/velofy/console/main.py index 8446905..0c7dac5 100644 --- a/src/velofy/console/main.py +++ b/src/velofy/console/main.py @@ -8,7 +8,12 @@ from click import core as cli_core import velofy -def show_version(ctx: cli_core.Context, _param: t.Any, value: bool) -> None: +def show_version( + ctx: cli_core.Context, + _param: t.Any, + # `click` passes all arguments to callbacks positionally + value: bool, # noqa:FBT001 +) -> None: """Show the package's version.""" # If --version / -V is NOT passed in, # continue with the command. diff --git a/src/velofy/db/addresses_addresses.py b/src/velofy/db/addresses_addresses.py index c36e878..14cb5c2 100644 --- a/src/velofy/db/addresses_addresses.py +++ b/src/velofy/db/addresses_addresses.py @@ -183,7 +183,7 @@ class Path(meta.Base): return paths @classmethod - def from_order(cls, order: db.Order, google_maps: bool = False) -> Path: + def from_order(cls, order: db.Order, *, google_maps: bool = False) -> Path: """Calculate the path for an `Order` object. The path goes from the `Order.pickup_address` to the `Order.delivery_address`. diff --git a/src/velofy/db/cities.py b/src/velofy/db/cities.py index 258add4..a6fc363 100644 --- a/src/velofy/db/cities.py +++ b/src/velofy/db/cities.py @@ -149,6 +149,7 @@ class City(meta.Base): def draw_restaurants( self, + *, order_counts: bool = False, # pragma: no cover ) -> folium.Map: """Draw all restaurants on the`.map`. diff --git a/src/velofy/db/customers.py b/src/velofy/db/customers.py index b047b24..b7b146c 100644 --- a/src/velofy/db/customers.py +++ b/src/velofy/db/customers.py @@ -46,6 +46,7 @@ class Customer(meta.Base): def draw( # noqa:C901,PLR0912 self, + *, restaurants: bool = True, order_counts: bool = False, # pragma: no cover ) -> folium.Map: diff --git a/src/velofy/db/pixels.py b/src/velofy/db/pixels.py index be6c5c6..981d821 100644 --- a/src/velofy/db/pixels.py +++ b/src/velofy/db/pixels.py @@ -158,6 +158,7 @@ class Pixel(meta.Base): def draw( # noqa:C901,PLR0912 self, + *, restaurants: bool = True, order_counts: bool = False, # pragma: no cover ) -> folium.Map: diff --git a/src/velofy/db/restaurants.py b/src/velofy/db/restaurants.py index bd4c467..73bb101 100644 --- a/src/velofy/db/restaurants.py +++ b/src/velofy/db/restaurants.py @@ -91,6 +91,7 @@ class Restaurant(meta.Base): def draw( self, + *, customers: bool = True, order_counts: bool = False, # pragma: no cover ) -> folium.Map: diff --git a/src/velofy/db/utils/colors.py b/src/velofy/db/utils/colors.py index 15e780f..c7cde67 100644 --- a/src/velofy/db/utils/colors.py +++ b/src/velofy/db/utils/colors.py @@ -8,6 +8,7 @@ from matplotlib import colors def make_random_cmap( n_colors: int, + *, bright: bool = True, # pragma: no cover ) -> colors.LinearSegmentedColormap: """Create a random `Colormap` with `n_colors` different colors. diff --git a/tests/db/fake_data/fixture_makers.py b/tests/db/fake_data/fixture_makers.py index 879f8b1..4cddf82 100644 --- a/tests/db/fake_data/fixture_makers.py +++ b/tests/db/fake_data/fixture_makers.py @@ -77,7 +77,7 @@ def make_order(make_address, make_courier, make_customer, make_restaurant): # Reset the identifiers before every test. factories.AdHocOrderFactory.reset_sequence(1) - def func(scheduled=False, restaurant=None, courier=None, **kwargs): + def func(*, scheduled=False, restaurant=None, courier=None, **kwargs): """Create a new `Order` object. Each `Order` is made by a new `Customer` with a unique `Address` for delivery. @@ -122,7 +122,7 @@ def make_replay_order(make_order, simulation): # Reset the identifiers before every test. factories.ReplayedOrderFactory.reset_sequence(1) - def func(scheduled=False, order=None, **kwargs): + def func(*, scheduled=False, order=None, **kwargs): """Create a new `ReplayedOrder` object. Each `ReplayOrder` is made by a new `Customer` with a unique `Address`. diff --git a/uv.lock b/uv.lock index ead69a0..0ea92f6 100644 --- a/uv.lock +++ b/uv.lock @@ -922,6 +922,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/00/ba/8950a5ef5180c089f5ae474b60555acb0c079bc2b5dd55b7e8193e01be87/flake8_black-0.5.0-py3-none-any.whl", hash = "sha256:28c16f3c5421d1831ce27177926dbaa1d6d460da475afdcd230d409c35495ae7", size = 10167, upload-time = "2026-11-03T11:59:13.491Z" }, ] +[[package]] +name = "flake8-boolean-trap" +version = "1.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/4f/8ba91d20f54227fa791c4a8e52b9c9b8330f1093da1666de16d4fc8621c7/flake8_boolean_trap-1.0.1.tar.gz", hash = "sha256:603becf640de095fa8ef5e7f8d9945c525ea6913a75df27408be380fd7e0cb3f", size = 4524, upload-time = "2023-07-17T17:01:05.094Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/4a/98ecacb66251c8afc8bb9d364995688215f33b451d58be8817b03e4d23b5/flake8_boolean_trap-1.0.1-py3-none-any.whl", hash = "sha256:8c21b1ce2591028750c7a61760df525361b26ef02bf0e8032082dc7fd0d0f377", size = 4430, upload-time = "2023-07-17T17:01:03.636Z" }, +] + [[package]] name = "flake8-broken-line" version = "1.0.0" @@ -3839,6 +3851,7 @@ dev = [ { name = "flake8-annotations" }, { name = "flake8-bandit" }, { name = "flake8-black" }, + { name = "flake8-boolean-trap" }, { name = "flake8-broken-line" }, { name = "flake8-bugbear" }, { name = "flake8-builtins" }, @@ -3910,6 +3923,7 @@ dev = [ { name = "flake8-annotations", specifier = ">=3.3.1,<4.0.0" }, { name = "flake8-bandit", specifier = ">=4.1.1,<5.0.0" }, { name = "flake8-black", specifier = ">=0.5.0,<0.6.0" }, + { name = "flake8-boolean-trap", specifier = ">=1.0.1,<2.0.0" }, { name = "flake8-broken-line", specifier = ">=1.0.0,<2.0.0" }, { name = "flake8-bugbear", specifier = ">=26.11.22,<27.0.0" }, { name = "flake8-builtins", specifier = ">=3.2.0,<4.0.0" },