diff --git a/noxfile.py b/noxfile.py index 0aca0c5..f79025c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -135,7 +135,6 @@ def lint(session): 'flake8', 'flake8-annotations', 'flake8-black', - 'flake8-expression-complexity', 'flake8-pytest-style', 'mypy', 'wemake-python-styleguide', diff --git a/poetry.lock b/poetry.lock index ec3647e..ea8ab06 100644 --- a/poetry.lock +++ b/poetry.lock @@ -73,17 +73,6 @@ category = "dev" optional = false 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]] name = "atomicwrites" version = "1.4.0" @@ -537,18 +526,6 @@ attrs = "*" eradicate = ">=1.0,<2.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]] name = "flake8-isort" version = "3.0.1" @@ -2136,7 +2113,7 @@ research = ["jupyterlab", "nb_black", "numpy", "pytz"] [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "f4dfe432ca7054f9be0e2ab189d3f6cd210dc51a2c2f2ded8b7d978620de9b51" +content-hash = "8fb55f96f74960bcdff195a20747ea93778f33fdf36f392d553e51565d442947" [metadata.files] alabaster = [ @@ -2176,10 +2153,6 @@ astor = [ {file = "astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5"}, {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 = [ {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, {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-py3-none-any.whl", hash = "sha256:e8b32b32300bfb407fe7ef74667c8d2d3a6a81bdf6f09c14a7bcc82b7b870f8b"}, ] -flake8-expression-complexity = [ - {file = "flake8_expression_complexity-0.0.8.tar.gz", hash = "sha256:c23f8ae677eb13b073be9bafa2cf443a87d3e2594817ba82c1f3e184e2de4afa"}, -] flake8-isort = [ {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"}, diff --git a/pyproject.toml b/pyproject.toml index 6d918e0..b268891 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,6 @@ isort = "^4.3.21" # TODO (isort): not ^5.5.4 due to wemake-python-styleguide flake8 = "^3.8.3" flake8-annotations = "^2.3.0" flake8-black = "^0.2.1" -flake8-expression-complexity = "^0.0.8" flake8-pytest-style = "^1.2.2" mypy = "^0.782" wemake-python-styleguide = "^0.14.1" # flake8 plug-in diff --git a/setup.cfg b/setup.cfg index 11b8ebd..e91e277 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,8 +72,6 @@ select = ANN0, ANN2, ANN3, # flake8-black => complain if black would make changes BLK1, BLK9, - # flake8-expression-complexity => not too many expressions at once - ECE001, # flake8-pytest-style => enforce a consistent style with pytest PT0, diff --git a/src/urban_meal_delivery/console/forecasts.py b/src/urban_meal_delivery/console/forecasts.py index d60b297..5d2a20d 100644 --- a/src/urban_meal_delivery/console/forecasts.py +++ b/src/urban_meal_delivery/console/forecasts.py @@ -103,7 +103,7 @@ def tactical_heuristic( # noqa:C901,WPS213,WPS216,WPS231 # Important: this check may need to be adapted once further # commands are added the make `Forecast`s without the heuristic! # 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 .join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id) .join(db.Grid, db.Pixel.grid_id == db.Grid.id) diff --git a/src/urban_meal_delivery/db/addresses_addresses.py b/src/urban_meal_delivery/db/addresses_addresses.py index 22aee70..15b8e24 100644 --- a/src/urban_meal_delivery/db/addresses_addresses.py +++ b/src/urban_meal_delivery/db/addresses_addresses.py @@ -129,7 +129,7 @@ class DistanceMatrix(meta.Base): ) # If there is no `DistanceMatrix` object in the database ... - distance = ( # noqa:ECE001 + distance = ( db.session.query(db.DistanceMatrix) .filter(db.DistanceMatrix.first_address == first) .filter(db.DistanceMatrix.second_address == second) diff --git a/src/urban_meal_delivery/db/cities.py b/src/urban_meal_delivery/db/cities.py index 318ede3..926b3ae 100644 --- a/src/urban_meal_delivery/db/cities.py +++ b/src/urban_meal_delivery/db/cities.py @@ -129,7 +129,7 @@ class City(meta.Base): `.map` for convenience in interactive usage """ # Obtain all primary `Address`es in the city that host `Restaurant`s. - addresses = ( # noqa:ECE001 + addresses = ( db.session.query(db.Address) .filter( db.Address.id.in_( @@ -146,7 +146,7 @@ class City(meta.Base): for address in addresses: # Show the restaurant's name if there is only one. # Otherwise, list all the restaurants' ID's. - restaurants = ( # noqa:ECE001 + restaurants = ( db.session.query(db.Restaurant) .join(db.Address, db.Restaurant.address_id == db.Address.id) .filter(db.Address.primary_id == address.id) @@ -161,7 +161,7 @@ class City(meta.Base): if order_counts: # Calculate the number of orders for ALL restaurants ... - n_orders = ( # noqa:ECE001 + n_orders = ( db.session.query(db.Order.id) .join(db.Address, db.Order.pickup_address_id == db.Address.id) .filter(db.Address.primary_id == address.id) diff --git a/src/urban_meal_delivery/db/customers.py b/src/urban_meal_delivery/db/customers.py index f6d59c2..e870de0 100644 --- a/src/urban_meal_delivery/db/customers.py +++ b/src/urban_meal_delivery/db/customers.py @@ -63,7 +63,7 @@ class Customer(meta.Base): # Obtain all primary `Address`es where # at least one delivery was made to `self`. - delivery_addresses = ( # noqa:ECE001 + delivery_addresses = ( db.session.query(db.Address) .filter( db.Address.id.in_( @@ -79,7 +79,7 @@ class Customer(meta.Base): for address in delivery_addresses: if order_counts: - n_orders = ( # noqa:ECE001 + n_orders = ( db.session.query(db.Order) .join(db.Address, db.Order.delivery_address_id == db.Address.id) .filter(db.Order.customer_id == self.id) @@ -111,7 +111,7 @@ class Customer(meta.Base): ) if restaurants: - pickup_addresses = ( # noqa:ECE001 + pickup_addresses = ( db.session.query(db.Address) .filter( db.Address.id.in_( @@ -129,7 +129,7 @@ class Customer(meta.Base): # Show the restaurant's name if there is only one. # Otherwise, list all the restaurants' ID's. # We cannot show the `Order.restaurant.name` due to the aggregation. - restaurants = ( # noqa:ECE001 + restaurants = ( db.session.query(db.Restaurant) .join(db.Address, db.Restaurant.address_id == db.Address.id) .filter(db.Address.primary_id == address.id) # noqa:WPS441 @@ -145,7 +145,7 @@ class Customer(meta.Base): ) if order_counts: - n_orders = ( # noqa:ECE001 + n_orders = ( db.session.query(db.Order) .join(db.Address, db.Order.pickup_address_id == db.Address.id) .filter(db.Order.customer_id == self.id) diff --git a/src/urban_meal_delivery/db/grids.py b/src/urban_meal_delivery/db/grids.py index dac6e48..9212d66 100644 --- a/src/urban_meal_delivery/db/grids.py +++ b/src/urban_meal_delivery/db/grids.py @@ -76,7 +76,7 @@ class Grid(meta.Base): # `Pixel`s grouped by `.n_x`-`.n_y` coordinates. pixels = {} - pickup_addresses = ( # noqa:ECE:001 + pickup_addresses = ( db.session.query(db.Address) .join(db.Order, db.Address.id == db.Order.pickup_address_id) .filter(db.Address.city == city) diff --git a/src/urban_meal_delivery/db/pixels.py b/src/urban_meal_delivery/db/pixels.py index eed2192..f063634 100644 --- a/src/urban_meal_delivery/db/pixels.py +++ b/src/urban_meal_delivery/db/pixels.py @@ -112,7 +112,7 @@ class Pixel(meta.Base): @functools.cached_property def restaurants(self) -> List[db.Restaurant]: # pragma: no cover """Obtain all `Restaurant`s in `self`.""" - return ( # noqa:ECE001 + return ( db.session.query(db.Restaurant) .join( db.AddressPixelAssociation, @@ -175,7 +175,7 @@ class Pixel(meta.Base): if restaurants: # Obtain all primary `Address`es in the city that host `Restaurant`s # and are in the `self` `Pixel`. - addresses = ( # noqa:ECE001 + addresses = ( db.session.query(db.Address) .filter( db.Address.id.in_( @@ -201,7 +201,7 @@ class Pixel(meta.Base): for address in addresses: # Show the restaurant's name if there is only one. # Otherwise, list all the restaurants' ID's. - restaurants = ( # noqa:ECE001 + restaurants = ( db.session.query(db.Restaurant) .join(db.Address, db.Restaurant.address_id == db.Address.id) .filter(db.Address.primary_id == address.id) @@ -218,7 +218,7 @@ class Pixel(meta.Base): if order_counts: # Calculate the number of orders for ALL restaurants ... - n_orders = ( # noqa:ECE001 + n_orders = ( db.session.query(db.Order.id) .join(db.Address, db.Order.pickup_address_id == db.Address.id) .filter(db.Address.primary_id == address.id) diff --git a/src/urban_meal_delivery/db/restaurants.py b/src/urban_meal_delivery/db/restaurants.py index cf02e53..9e6a2b6 100644 --- a/src/urban_meal_delivery/db/restaurants.py +++ b/src/urban_meal_delivery/db/restaurants.py @@ -83,7 +83,7 @@ class Restaurant(meta.Base): if customers: # Obtain all primary `Address`es in the city that # received at least one delivery from `self`. - delivery_addresses = ( # noqa:ECE001 + delivery_addresses = ( db.session.query(db.Address) .filter( db.Address.id.in_( @@ -99,7 +99,7 @@ class Restaurant(meta.Base): for address in delivery_addresses: if order_counts: - n_orders = ( # noqa:ECE001 + n_orders = ( db.session.query(db.Order) .join(db.Address, db.Order.delivery_address_id == db.Address.id) .filter(db.Order.restaurant_id == self.id) diff --git a/src/urban_meal_delivery/forecasts/models/base.py b/src/urban_meal_delivery/forecasts/models/base.py index 9a9cd72..9c3977a 100644 --- a/src/urban_meal_delivery/forecasts/models/base.py +++ b/src/urban_meal_delivery/forecasts/models/base.py @@ -75,7 +75,7 @@ class ForecastingModelABC(abc.ABC): # noqa:DAR401 RuntimeError """ 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(start_at=predict_at) .filter_by(time_step=self._order_history.time_step)