Remove flake8-expression-complexity ...

... from the dev dependencies.

Longer queries in SQLAlchemy get flagged even though they are not
complicated. Other expressions are generally not that complicated.
This commit is contained in:
Alexander Hess 2021-09-08 14:24:16 +02:00
parent 1c19da2f70
commit 3bef9ca38d
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
12 changed files with 19 additions and 53 deletions

View file

@ -135,7 +135,6 @@ def lint(session):
'flake8', 'flake8',
'flake8-annotations', 'flake8-annotations',
'flake8-black', 'flake8-black',
'flake8-expression-complexity',
'flake8-pytest-style', 'flake8-pytest-style',
'mypy', 'mypy',
'wemake-python-styleguide', 'wemake-python-styleguide',

32
poetry.lock generated
View file

@ -73,17 +73,6 @@ category = "dev"
optional = false optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
[[package]]
name = "astpretty"
version = "2.1.0"
description = "Pretty print the output of python stdlib `ast.parse`."
category = "dev"
optional = false
python-versions = ">=3.6.1"
[package.extras]
typed = ["typed-ast"]
[[package]] [[package]]
name = "atomicwrites" name = "atomicwrites"
version = "1.4.0" version = "1.4.0"
@ -537,18 +526,6 @@ attrs = "*"
eradicate = ">=1.0,<2.0" eradicate = ">=1.0,<2.0"
flake8 = ">=3.5,<4.0" flake8 = ">=3.5,<4.0"
[[package]]
name = "flake8-expression-complexity"
version = "0.0.8"
description = "A flake8 extension that checks expressions complexity"
category = "dev"
optional = false
python-versions = ">=3.6"
[package.dependencies]
astpretty = "*"
flake8 = "*"
[[package]] [[package]]
name = "flake8-isort" name = "flake8-isort"
version = "3.0.1" version = "3.0.1"
@ -2136,7 +2113,7 @@ research = ["jupyterlab", "nb_black", "numpy", "pytz"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "f4dfe432ca7054f9be0e2ab189d3f6cd210dc51a2c2f2ded8b7d978620de9b51" content-hash = "8fb55f96f74960bcdff195a20747ea93778f33fdf36f392d553e51565d442947"
[metadata.files] [metadata.files]
alabaster = [ alabaster = [
@ -2176,10 +2153,6 @@ astor = [
{file = "astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5"}, {file = "astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5"},
{file = "astor-0.8.1.tar.gz", hash = "sha256:6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e"}, {file = "astor-0.8.1.tar.gz", hash = "sha256:6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e"},
] ]
astpretty = [
{file = "astpretty-2.1.0-py2.py3-none-any.whl", hash = "sha256:f81f14b5636f7af81fadb1e3c09ca7702ce4615500d9cc6d6829befb2dec2e3c"},
{file = "astpretty-2.1.0.tar.gz", hash = "sha256:8a801fcda604ec741f010bb36d7cbadc3ec8a182ea6fb83e20ab663463e75ff6"},
]
atomicwrites = [ atomicwrites = [
{file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"},
{file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, {file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"},
@ -2467,9 +2440,6 @@ flake8-eradicate = [
{file = "flake8-eradicate-0.3.0.tar.gz", hash = "sha256:d0b3d283d85079917acbfe39b9d637385cd82cba3ae3d76c1278c07ddcf0d9b9"}, {file = "flake8-eradicate-0.3.0.tar.gz", hash = "sha256:d0b3d283d85079917acbfe39b9d637385cd82cba3ae3d76c1278c07ddcf0d9b9"},
{file = "flake8_eradicate-0.3.0-py3-none-any.whl", hash = "sha256:e8b32b32300bfb407fe7ef74667c8d2d3a6a81bdf6f09c14a7bcc82b7b870f8b"}, {file = "flake8_eradicate-0.3.0-py3-none-any.whl", hash = "sha256:e8b32b32300bfb407fe7ef74667c8d2d3a6a81bdf6f09c14a7bcc82b7b870f8b"},
] ]
flake8-expression-complexity = [
{file = "flake8_expression_complexity-0.0.8.tar.gz", hash = "sha256:c23f8ae677eb13b073be9bafa2cf443a87d3e2594817ba82c1f3e184e2de4afa"},
]
flake8-isort = [ flake8-isort = [
{file = "flake8-isort-3.0.1.tar.gz", hash = "sha256:5d976da513cc390232ad5a9bb54aee8a092466a15f442d91dfc525834bee727a"}, {file = "flake8-isort-3.0.1.tar.gz", hash = "sha256:5d976da513cc390232ad5a9bb54aee8a092466a15f442d91dfc525834bee727a"},
{file = "flake8_isort-3.0.1-py2.py3-none-any.whl", hash = "sha256:df1dd6dd73f6a8b128c9c783356627231783cccc82c13c6dc343d1a5a491699b"}, {file = "flake8_isort-3.0.1-py2.py3-none-any.whl", hash = "sha256:df1dd6dd73f6a8b128c9c783356627231783cccc82c13c6dc343d1a5a491699b"},

View file

@ -72,7 +72,6 @@ isort = "^4.3.21" # TODO (isort): not ^5.5.4 due to wemake-python-styleguide
flake8 = "^3.8.3" flake8 = "^3.8.3"
flake8-annotations = "^2.3.0" flake8-annotations = "^2.3.0"
flake8-black = "^0.2.1" flake8-black = "^0.2.1"
flake8-expression-complexity = "^0.0.8"
flake8-pytest-style = "^1.2.2" flake8-pytest-style = "^1.2.2"
mypy = "^0.782" mypy = "^0.782"
wemake-python-styleguide = "^0.14.1" # flake8 plug-in wemake-python-styleguide = "^0.14.1" # flake8 plug-in

View file

@ -72,8 +72,6 @@ select =
ANN0, ANN2, ANN3, ANN0, ANN2, ANN3,
# flake8-black => complain if black would make changes # flake8-black => complain if black would make changes
BLK1, BLK9, BLK1, BLK9,
# flake8-expression-complexity => not too many expressions at once
ECE001,
# flake8-pytest-style => enforce a consistent style with pytest # flake8-pytest-style => enforce a consistent style with pytest
PT0, PT0,

View file

@ -103,7 +103,7 @@ def tactical_heuristic( # noqa:C901,WPS213,WPS216,WPS231
# Important: this check may need to be adapted once further # Important: this check may need to be adapted once further
# commands are added the make `Forecast`s without the heuristic! # commands are added the make `Forecast`s without the heuristic!
# Continue with forecasting on the day the last prediction was made ... # Continue with forecasting on the day the last prediction was made ...
last_predict_at = ( # noqa:ECE001 last_predict_at = (
db.session.query(func.max(db.Forecast.start_at)) # noqa:WPS221 db.session.query(func.max(db.Forecast.start_at)) # noqa:WPS221
.join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id) .join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id)
.join(db.Grid, db.Pixel.grid_id == db.Grid.id) .join(db.Grid, db.Pixel.grid_id == db.Grid.id)

View file

@ -129,7 +129,7 @@ class DistanceMatrix(meta.Base):
) )
# If there is no `DistanceMatrix` object in the database ... # If there is no `DistanceMatrix` object in the database ...
distance = ( # noqa:ECE001 distance = (
db.session.query(db.DistanceMatrix) db.session.query(db.DistanceMatrix)
.filter(db.DistanceMatrix.first_address == first) .filter(db.DistanceMatrix.first_address == first)
.filter(db.DistanceMatrix.second_address == second) .filter(db.DistanceMatrix.second_address == second)

View file

@ -129,7 +129,7 @@ class City(meta.Base):
`.map` for convenience in interactive usage `.map` for convenience in interactive usage
""" """
# Obtain all primary `Address`es in the city that host `Restaurant`s. # Obtain all primary `Address`es in the city that host `Restaurant`s.
addresses = ( # noqa:ECE001 addresses = (
db.session.query(db.Address) db.session.query(db.Address)
.filter( .filter(
db.Address.id.in_( db.Address.id.in_(
@ -146,7 +146,7 @@ class City(meta.Base):
for address in addresses: for address in addresses:
# Show the restaurant's name if there is only one. # Show the restaurant's name if there is only one.
# Otherwise, list all the restaurants' ID's. # Otherwise, list all the restaurants' ID's.
restaurants = ( # noqa:ECE001 restaurants = (
db.session.query(db.Restaurant) db.session.query(db.Restaurant)
.join(db.Address, db.Restaurant.address_id == db.Address.id) .join(db.Address, db.Restaurant.address_id == db.Address.id)
.filter(db.Address.primary_id == address.id) .filter(db.Address.primary_id == address.id)
@ -161,7 +161,7 @@ class City(meta.Base):
if order_counts: if order_counts:
# Calculate the number of orders for ALL restaurants ... # Calculate the number of orders for ALL restaurants ...
n_orders = ( # noqa:ECE001 n_orders = (
db.session.query(db.Order.id) db.session.query(db.Order.id)
.join(db.Address, db.Order.pickup_address_id == db.Address.id) .join(db.Address, db.Order.pickup_address_id == db.Address.id)
.filter(db.Address.primary_id == address.id) .filter(db.Address.primary_id == address.id)

View file

@ -63,7 +63,7 @@ class Customer(meta.Base):
# Obtain all primary `Address`es where # Obtain all primary `Address`es where
# at least one delivery was made to `self`. # at least one delivery was made to `self`.
delivery_addresses = ( # noqa:ECE001 delivery_addresses = (
db.session.query(db.Address) db.session.query(db.Address)
.filter( .filter(
db.Address.id.in_( db.Address.id.in_(
@ -79,7 +79,7 @@ class Customer(meta.Base):
for address in delivery_addresses: for address in delivery_addresses:
if order_counts: if order_counts:
n_orders = ( # noqa:ECE001 n_orders = (
db.session.query(db.Order) db.session.query(db.Order)
.join(db.Address, db.Order.delivery_address_id == db.Address.id) .join(db.Address, db.Order.delivery_address_id == db.Address.id)
.filter(db.Order.customer_id == self.id) .filter(db.Order.customer_id == self.id)
@ -111,7 +111,7 @@ class Customer(meta.Base):
) )
if restaurants: if restaurants:
pickup_addresses = ( # noqa:ECE001 pickup_addresses = (
db.session.query(db.Address) db.session.query(db.Address)
.filter( .filter(
db.Address.id.in_( db.Address.id.in_(
@ -129,7 +129,7 @@ class Customer(meta.Base):
# Show the restaurant's name if there is only one. # Show the restaurant's name if there is only one.
# Otherwise, list all the restaurants' ID's. # Otherwise, list all the restaurants' ID's.
# We cannot show the `Order.restaurant.name` due to the aggregation. # We cannot show the `Order.restaurant.name` due to the aggregation.
restaurants = ( # noqa:ECE001 restaurants = (
db.session.query(db.Restaurant) db.session.query(db.Restaurant)
.join(db.Address, db.Restaurant.address_id == db.Address.id) .join(db.Address, db.Restaurant.address_id == db.Address.id)
.filter(db.Address.primary_id == address.id) # noqa:WPS441 .filter(db.Address.primary_id == address.id) # noqa:WPS441
@ -145,7 +145,7 @@ class Customer(meta.Base):
) )
if order_counts: if order_counts:
n_orders = ( # noqa:ECE001 n_orders = (
db.session.query(db.Order) db.session.query(db.Order)
.join(db.Address, db.Order.pickup_address_id == db.Address.id) .join(db.Address, db.Order.pickup_address_id == db.Address.id)
.filter(db.Order.customer_id == self.id) .filter(db.Order.customer_id == self.id)

View file

@ -76,7 +76,7 @@ class Grid(meta.Base):
# `Pixel`s grouped by `.n_x`-`.n_y` coordinates. # `Pixel`s grouped by `.n_x`-`.n_y` coordinates.
pixels = {} pixels = {}
pickup_addresses = ( # noqa:ECE:001 pickup_addresses = (
db.session.query(db.Address) db.session.query(db.Address)
.join(db.Order, db.Address.id == db.Order.pickup_address_id) .join(db.Order, db.Address.id == db.Order.pickup_address_id)
.filter(db.Address.city == city) .filter(db.Address.city == city)

View file

@ -112,7 +112,7 @@ class Pixel(meta.Base):
@functools.cached_property @functools.cached_property
def restaurants(self) -> List[db.Restaurant]: # pragma: no cover def restaurants(self) -> List[db.Restaurant]: # pragma: no cover
"""Obtain all `Restaurant`s in `self`.""" """Obtain all `Restaurant`s in `self`."""
return ( # noqa:ECE001 return (
db.session.query(db.Restaurant) db.session.query(db.Restaurant)
.join( .join(
db.AddressPixelAssociation, db.AddressPixelAssociation,
@ -175,7 +175,7 @@ class Pixel(meta.Base):
if restaurants: if restaurants:
# Obtain all primary `Address`es in the city that host `Restaurant`s # Obtain all primary `Address`es in the city that host `Restaurant`s
# and are in the `self` `Pixel`. # and are in the `self` `Pixel`.
addresses = ( # noqa:ECE001 addresses = (
db.session.query(db.Address) db.session.query(db.Address)
.filter( .filter(
db.Address.id.in_( db.Address.id.in_(
@ -201,7 +201,7 @@ class Pixel(meta.Base):
for address in addresses: for address in addresses:
# Show the restaurant's name if there is only one. # Show the restaurant's name if there is only one.
# Otherwise, list all the restaurants' ID's. # Otherwise, list all the restaurants' ID's.
restaurants = ( # noqa:ECE001 restaurants = (
db.session.query(db.Restaurant) db.session.query(db.Restaurant)
.join(db.Address, db.Restaurant.address_id == db.Address.id) .join(db.Address, db.Restaurant.address_id == db.Address.id)
.filter(db.Address.primary_id == address.id) .filter(db.Address.primary_id == address.id)
@ -218,7 +218,7 @@ class Pixel(meta.Base):
if order_counts: if order_counts:
# Calculate the number of orders for ALL restaurants ... # Calculate the number of orders for ALL restaurants ...
n_orders = ( # noqa:ECE001 n_orders = (
db.session.query(db.Order.id) db.session.query(db.Order.id)
.join(db.Address, db.Order.pickup_address_id == db.Address.id) .join(db.Address, db.Order.pickup_address_id == db.Address.id)
.filter(db.Address.primary_id == address.id) .filter(db.Address.primary_id == address.id)

View file

@ -83,7 +83,7 @@ class Restaurant(meta.Base):
if customers: if customers:
# Obtain all primary `Address`es in the city that # Obtain all primary `Address`es in the city that
# received at least one delivery from `self`. # received at least one delivery from `self`.
delivery_addresses = ( # noqa:ECE001 delivery_addresses = (
db.session.query(db.Address) db.session.query(db.Address)
.filter( .filter(
db.Address.id.in_( db.Address.id.in_(
@ -99,7 +99,7 @@ class Restaurant(meta.Base):
for address in delivery_addresses: for address in delivery_addresses:
if order_counts: if order_counts:
n_orders = ( # noqa:ECE001 n_orders = (
db.session.query(db.Order) db.session.query(db.Order)
.join(db.Address, db.Order.delivery_address_id == db.Address.id) .join(db.Address, db.Order.delivery_address_id == db.Address.id)
.filter(db.Order.restaurant_id == self.id) .filter(db.Order.restaurant_id == self.id)

View file

@ -75,7 +75,7 @@ class ForecastingModelABC(abc.ABC):
# noqa:DAR401 RuntimeError # noqa:DAR401 RuntimeError
""" """
if ( # noqa:WPS337 if ( # noqa:WPS337
cached_forecast := db.session.query(db.Forecast) # noqa:ECE001,WPS221 cached_forecast := db.session.query(db.Forecast) # noqa:WPS221
.filter_by(pixel=pixel) .filter_by(pixel=pixel)
.filter_by(start_at=predict_at) .filter_by(start_at=predict_at)
.filter_by(time_step=self._order_history.time_step) .filter_by(time_step=self._order_history.time_step)