Enable FBT in flake8 and ruff
This commit is contained in:
parent
d0326aee4f
commit
5beb88559f
11 changed files with 36 additions and 4 deletions
|
|
@ -194,6 +194,7 @@ def lint_code(session: nox.Session) -> None:
|
||||||
"flake8-annotations",
|
"flake8-annotations",
|
||||||
"flake8-bandit",
|
"flake8-bandit",
|
||||||
"flake8-black",
|
"flake8-black",
|
||||||
|
"flake8-boolean-trap",
|
||||||
"flake8-broken-line",
|
"flake8-broken-line",
|
||||||
"flake8-bugbear",
|
"flake8-bugbear",
|
||||||
"flake8-builtins",
|
"flake8-builtins",
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ dev = [
|
||||||
"flake8-annotations (>=3.3.1,<4.0.0)",
|
"flake8-annotations (>=3.3.1,<4.0.0)",
|
||||||
"flake8-bandit (>=4.1.1,<5.0.0)",
|
"flake8-bandit (>=4.1.1,<5.0.0)",
|
||||||
"flake8-black (>=0.5.0,<0.6.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-broken-line (>=1.0.0,<2.0.0)",
|
||||||
"flake8-bugbear (>=26.11.22,<27.0.0)",
|
"flake8-bugbear (>=26.11.22,<27.0.0)",
|
||||||
"flake8-builtins (>=3.2.0,<4.0.0)",
|
"flake8-builtins (>=3.2.0,<4.0.0)",
|
||||||
|
|
@ -210,6 +211,8 @@ select = [
|
||||||
"S1", "S2", "S3", "S4", "S5", "S6", "S7",
|
"S1", "S2", "S3", "S4", "S5", "S6", "S7",
|
||||||
# flake8-black => complain if black would make changes
|
# flake8-black => complain if black would make changes
|
||||||
"BLK1", "BLK9",
|
"BLK1", "BLK9",
|
||||||
|
# flake8-boolean-trap => Keyword-only flags
|
||||||
|
"FBT",
|
||||||
# flake8-broken-line => no \ to end a line
|
# flake8-broken-line => no \ to end a line
|
||||||
"N400",
|
"N400",
|
||||||
# flake8-bugbear => opinionated bugs and design flaws
|
# flake8-bugbear => opinionated bugs and design flaws
|
||||||
|
|
@ -279,6 +282,8 @@ extend-ignore = [
|
||||||
# Comply with black's style.
|
# Comply with black's style.
|
||||||
# Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8
|
# Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8
|
||||||
"E203", "W503",
|
"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).
|
# Every `.add()` looks like `pandas` to this rule (`ruff` omits it).
|
||||||
"PD005",
|
"PD005",
|
||||||
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
|
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
|
||||||
|
|
@ -506,6 +511,8 @@ select = [
|
||||||
"E", "W",
|
"E", "W",
|
||||||
# pyflakes => basic errors
|
# pyflakes => basic errors
|
||||||
"F",
|
"F",
|
||||||
|
# flake8-boolean-trap => Keyword-only flags
|
||||||
|
"FBT",
|
||||||
# flake8-implicit-str-concat => Unified string concatenation
|
# flake8-implicit-str-concat => Unified string concatenation
|
||||||
"ISC",
|
"ISC",
|
||||||
# pep8-naming => PEP8 naming conventions
|
# pep8-naming => PEP8 naming conventions
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,12 @@ from click import core as cli_core
|
||||||
import velofy
|
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."""
|
"""Show the package's version."""
|
||||||
# If --version / -V is NOT passed in,
|
# If --version / -V is NOT passed in,
|
||||||
# continue with the command.
|
# continue with the command.
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ class Path(meta.Base):
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
@classmethod
|
@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.
|
"""Calculate the path for an `Order` object.
|
||||||
|
|
||||||
The path goes from the `Order.pickup_address` to the `Order.delivery_address`.
|
The path goes from the `Order.pickup_address` to the `Order.delivery_address`.
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,7 @@ class City(meta.Base):
|
||||||
|
|
||||||
def draw_restaurants(
|
def draw_restaurants(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
order_counts: bool = False, # pragma: no cover
|
order_counts: bool = False, # pragma: no cover
|
||||||
) -> folium.Map:
|
) -> folium.Map:
|
||||||
"""Draw all restaurants on the`.map`.
|
"""Draw all restaurants on the`.map`.
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ class Customer(meta.Base):
|
||||||
|
|
||||||
def draw( # noqa:C901,PLR0912
|
def draw( # noqa:C901,PLR0912
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
restaurants: bool = True,
|
restaurants: bool = True,
|
||||||
order_counts: bool = False, # pragma: no cover
|
order_counts: bool = False, # pragma: no cover
|
||||||
) -> folium.Map:
|
) -> folium.Map:
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,7 @@ class Pixel(meta.Base):
|
||||||
|
|
||||||
def draw( # noqa:C901,PLR0912
|
def draw( # noqa:C901,PLR0912
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
restaurants: bool = True,
|
restaurants: bool = True,
|
||||||
order_counts: bool = False, # pragma: no cover
|
order_counts: bool = False, # pragma: no cover
|
||||||
) -> folium.Map:
|
) -> folium.Map:
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ class Restaurant(meta.Base):
|
||||||
|
|
||||||
def draw(
|
def draw(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
customers: bool = True,
|
customers: bool = True,
|
||||||
order_counts: bool = False, # pragma: no cover
|
order_counts: bool = False, # pragma: no cover
|
||||||
) -> folium.Map:
|
) -> folium.Map:
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from matplotlib import colors
|
||||||
|
|
||||||
def make_random_cmap(
|
def make_random_cmap(
|
||||||
n_colors: int,
|
n_colors: int,
|
||||||
|
*,
|
||||||
bright: bool = True, # pragma: no cover
|
bright: bool = True, # pragma: no cover
|
||||||
) -> colors.LinearSegmentedColormap:
|
) -> colors.LinearSegmentedColormap:
|
||||||
"""Create a random `Colormap` with `n_colors` different colors.
|
"""Create a random `Colormap` with `n_colors` different colors.
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ def make_order(make_address, make_courier, make_customer, make_restaurant):
|
||||||
# Reset the identifiers before every test.
|
# Reset the identifiers before every test.
|
||||||
factories.AdHocOrderFactory.reset_sequence(1)
|
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.
|
"""Create a new `Order` object.
|
||||||
|
|
||||||
Each `Order` is made by a new `Customer` with a unique `Address` for delivery.
|
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.
|
# Reset the identifiers before every test.
|
||||||
factories.ReplayedOrderFactory.reset_sequence(1)
|
factories.ReplayedOrderFactory.reset_sequence(1)
|
||||||
|
|
||||||
def func(scheduled=False, order=None, **kwargs):
|
def func(*, scheduled=False, order=None, **kwargs):
|
||||||
"""Create a new `ReplayedOrder` object.
|
"""Create a new `ReplayedOrder` object.
|
||||||
|
|
||||||
Each `ReplayOrder` is made by a new `Customer` with a unique `Address`.
|
Each `ReplayOrder` is made by a new `Customer` with a unique `Address`.
|
||||||
|
|
|
||||||
14
uv.lock
generated
14
uv.lock
generated
|
|
@ -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" },
|
{ 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]]
|
[[package]]
|
||||||
name = "flake8-broken-line"
|
name = "flake8-broken-line"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
@ -3839,6 +3851,7 @@ dev = [
|
||||||
{ name = "flake8-annotations" },
|
{ name = "flake8-annotations" },
|
||||||
{ name = "flake8-bandit" },
|
{ name = "flake8-bandit" },
|
||||||
{ name = "flake8-black" },
|
{ name = "flake8-black" },
|
||||||
|
{ name = "flake8-boolean-trap" },
|
||||||
{ name = "flake8-broken-line" },
|
{ name = "flake8-broken-line" },
|
||||||
{ name = "flake8-bugbear" },
|
{ name = "flake8-bugbear" },
|
||||||
{ name = "flake8-builtins" },
|
{ name = "flake8-builtins" },
|
||||||
|
|
@ -3910,6 +3923,7 @@ dev = [
|
||||||
{ name = "flake8-annotations", specifier = ">=3.3.1,<4.0.0" },
|
{ name = "flake8-annotations", specifier = ">=3.3.1,<4.0.0" },
|
||||||
{ name = "flake8-bandit", specifier = ">=4.1.1,<5.0.0" },
|
{ name = "flake8-bandit", specifier = ">=4.1.1,<5.0.0" },
|
||||||
{ name = "flake8-black", specifier = ">=0.5.0,<0.6.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-broken-line", specifier = ">=1.0.0,<2.0.0" },
|
||||||
{ name = "flake8-bugbear", specifier = ">=26.11.22,<27.0.0" },
|
{ name = "flake8-bugbear", specifier = ">=26.11.22,<27.0.0" },
|
||||||
{ name = "flake8-builtins", specifier = ">=3.2.0,<4.0.0" },
|
{ name = "flake8-builtins", specifier = ">=3.2.0,<4.0.0" },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue