There is no 'too complex function'

We check a function's cognitive complexity only with `mccabe` (=C901)
and not with WPS231 as the two overlap in most cases.
This commit is contained in:
Alexander Hess 2021-09-15 14:51:56 +02:00
parent 6091ad95c6
commit f0eb9d3b6f
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
10 changed files with 13 additions and 12 deletions

View file

@ -384,7 +384,7 @@ def test_suite(session):
@nox.session(name='fix-branch-references', python=PYTHON, venv_backend='none')
def fix_branch_references(session): # noqa:WPS210,WPS231
def fix_branch_references(session): # noqa:WPS210
"""Replace branch references with the current branch.
Intended to be run as a pre-commit hook.
@ -511,7 +511,7 @@ def init_project(session):
@nox.session(name='clean-pwd', python=PYTHON, venv_backend='none')
def clean_pwd(session): # noqa:WPS231
def clean_pwd(session):
"""Remove (almost) all glob patterns listed in .gitignore.
The difference compared to `git clean -X` is that this task

View file

@ -97,6 +97,9 @@ extend-ignore =
WPS220,
# String constant over-use is checked visually by the programmer.
WPS226,
# Function complexity is checked by `mccabe` (=C901),
# which yields the same result in most cases.
WPS231,
# Modules as a whole are assumed to be not "too complex".
WPS232,
# Allow underscores in numbers.

View file

@ -24,7 +24,7 @@ from urban_meal_delivery.forecasts import timify
@click.argument('time_step', default=60, type=int)
@click.argument('train_horizon', default=8, type=int)
@decorators.db_revision('8bfb928a31f8')
def tactical_heuristic( # noqa:C901,WPS213,WPS216,WPS231
def tactical_heuristic( # noqa:C901,WPS213,WPS216
city: str, side_length: int, time_step: int, train_horizon: int,
) -> None: # pragma: no cover
"""Predict demand for all pixels and days in a city.

View file

@ -117,7 +117,7 @@ class City(meta.Base):
return self._map
def draw_restaurants( # noqa:WPS231
def draw_restaurants(
self, order_counts: bool = False, # pragma: no cover
) -> folium.Map:
"""Draw all restaurants on the`.map`.

View file

@ -42,7 +42,7 @@ class Customer(meta.Base):
"""Shortcut to the `...city.map` object."""
return self.orders[0].pickup_address.city.map # noqa:WPS219
def draw( # noqa:C901,WPS210,WPS231
def draw( # noqa:C901,WPS210
self, restaurants: bool = True, order_counts: bool = False, # pragma: no cover
) -> folium.Map:
"""Draw all the customer's delivery addresses on the `...city.map`.

View file

@ -136,7 +136,7 @@ class Pixel(meta.Base):
"""Shortcut to the `.city.map` object."""
return self.grid.city.map
def draw( # noqa:C901,WPS210,WPS231
def draw( # noqa:C901,WPS210
self, restaurants: bool = True, order_counts: bool = False, # pragma: no cover
) -> folium.Map:
"""Draw the pixel on the `.grid.city.map`.

View file

@ -69,7 +69,7 @@ class Restaurant(meta.Base):
"""Shortcut to the `.address.city.map` object."""
return self.address.city.map
def draw( # noqa:WPS231
def draw(
self, customers: bool = True, order_counts: bool = False, # pragma: no cover
) -> folium.Map:
"""Draw the restaurant on the `.address.city.map`.

View file

@ -11,7 +11,7 @@ from rpy2 import robjects
from rpy2.robjects import pandas2ri
def stl( # noqa:C901,WPS210,WPS211,WPS231
def stl( # noqa:C901,WPS210,WPS211
time_series: pd.Series,
*,
frequency: int,

View file

@ -186,9 +186,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
)
@factory.post_generation
def post( # noqa:C901,WPS231
obj, create, extracted, **kwargs, # noqa:B902,N805
):
def post(obj, _create, _extracted, **_kwargs): # noqa:B902,C901,N805
"""Discard timestamps that occur after cancellation."""
if obj.cancelled:
if obj.cancelled_at <= obj.restaurant_notified_at:

View file

@ -422,7 +422,7 @@ class TestProperties:
@pytest.mark.db
@pytest.mark.no_cover
def test_make_random_orders( # noqa:C901,WPS211,WPS213,WPS231
def test_make_random_orders( # noqa:C901,WPS211,WPS213
db_session, make_address, make_courier, make_restaurant, make_order,
):
"""Sanity check the all the `make_*` fixtures.