Remove all "WPS" codes

This commit is contained in:
Alexander Hess 2026-11-28 02:01:12 +01:00
commit 9fcb3c8c14
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
20 changed files with 171 additions and 254 deletions

View file

@ -8,7 +8,7 @@ from velofy.console import gridify
@pytest.mark.db
def test_two_pixels_with_two_addresses( # noqa:WPS211
def test_two_pixels_with_two_addresses(
cli,
db_session,
monkeypatch,

View file

@ -17,7 +17,7 @@ class AddressFactory(alchemy.SQLAlchemyModelFactory):
model = db.Address
sqlalchemy_get_or_create = ('id',)
id = factory.Sequence(lambda num: num) # noqa:WPS125
id = factory.Sequence(lambda num: num)
created_at = factory.LazyFunction(utils.early_in_the_morning)
# When testing, all addresses are considered primary ones.

View file

@ -14,7 +14,7 @@ class CourierFactory(alchemy.SQLAlchemyModelFactory):
model = db.Courier
sqlalchemy_get_or_create = ('id',)
id = factory.Sequence(lambda num: num) # noqa:WPS125
id = factory.Sequence(lambda num: num)
created_at = factory.LazyFunction(utils.early_in_the_morning)
vehicle = 'bicycle'
historic_speed = 7.89

View file

@ -13,4 +13,4 @@ class CustomerFactory(alchemy.SQLAlchemyModelFactory):
model = db.Customer
sqlalchemy_get_or_create = ('id',)
id = factory.Sequence(lambda num: num) # noqa:WPS125
id = factory.Sequence(lambda num: num)

View file

@ -41,7 +41,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
# Timestamps after `cancelled_at` are discarded
# by the `post_generation` hook at the end of the `OrderFactory`.
cancel_ = factory.Trait( # noqa:WPS120 -> leading underscore does not work
cancel_ = factory.Trait( # -> leading underscore does not work
cancelled=True,
cancelled_at_corrected=False,
)
@ -65,7 +65,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
)
# Generic attributes
id = factory.Sequence(lambda num: num) # noqa:WPS125
id = factory.Sequence(lambda num: num)
# customer -> set by the `make_order` fixture for better control
# Attributes regarding the specialization of an `Order`: ad-hoc or scheduled.
@ -182,7 +182,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
# Statistical attributes -> calculate realistic stats
logged_delivery_distance = factory.LazyAttribute(
lambda obj: distance.great_circle( # noqa:WPS317
lambda obj: distance.great_circle(
(obj.pickup_address.latitude, obj.pickup_address.longitude),
(obj.delivery_address.latitude, obj.delivery_address.longitude),
).meters,

View file

@ -18,7 +18,7 @@ class RestaurantFactory(alchemy.SQLAlchemyModelFactory):
model = db.Restaurant
sqlalchemy_get_or_create = ('id',)
id = factory.Sequence(lambda num: num) # noqa:WPS125
id = factory.Sequence(lambda num: num)
created_at = factory.LazyFunction(utils.early_in_the_morning)
name = factory.LazyFunction(
lambda: f"{_restaurant_names.first_name()}'s Restaurant",

View file

@ -6,7 +6,7 @@ import random
from tests import config as test_config
def random_timespan( # noqa:WPS211
def random_timespan(
*,
min_hours=0,
min_minutes=0,

View file

@ -21,7 +21,7 @@ def another_address(make_address):
@pytest.fixture
def path(address, another_address, make_address):
"""A `Path` from `address` to `another_address`."""
air_distance = distance.great_circle( # noqa:WPS317
air_distance = distance.great_circle(
address.location.lat_lng,
another_address.location.lat_lng,
).meters
@ -31,7 +31,7 @@ def path(address, another_address, make_address):
directions = json.dumps(
[
(float(add.latitude), float(add.longitude))
for add in (make_address() for _ in range(5)) # noqa:WPS335
for add in (make_address() for _ in range(5))
],
)

View file

@ -376,7 +376,7 @@ class TestConstraints:
forecast.low95 = None
forecast.high95 = None
forecast.low80, forecast.high80 = ( # noqa:WPS414
forecast.low80, forecast.high80 = (
forecast.high80,
forecast.low80,
)
@ -398,7 +398,7 @@ class TestConstraints:
forecast.low80 = None
forecast.high80 = None
forecast.low95, forecast.high95 = ( # noqa:WPS414
forecast.low95, forecast.high95 = (
forecast.high95,
forecast.low95,
)
@ -416,7 +416,7 @@ class TestConstraints:
assert forecast.low80 is not None
assert forecast.low95 is not None
forecast.low80, forecast.low95 = (forecast.low95, forecast.low80) # noqa:WPS414
forecast.low80, forecast.low95 = (forecast.low95, forecast.low80)
db_session.add(forecast)
@ -431,7 +431,7 @@ class TestConstraints:
assert forecast.high80 is not None
assert forecast.high95 is not None
forecast.high80, forecast.high95 = ( # noqa:WPS414
forecast.high80, forecast.high95 = (
forecast.high95,
forecast.high80,
)

View file

@ -84,7 +84,7 @@ class TestGridification:
"""
mock = mocker.Mock()
query = ( # noqa:ECE001
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501,WPS219
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
)
monkeypatch.setattr(db, 'session', mock)
@ -105,7 +105,7 @@ class TestGridification:
result = db.Grid.gridify(city=city, side_length=side_length)
assert isinstance(result, db.Grid)
assert len(result.pixels) == 0 # noqa:WPS507
assert len(result.pixels) == 0
def test_one_pixel_with_one_address(self, city, order, addresses_mock):
"""At the very least, there must be one `Pixel` ...
@ -155,7 +155,7 @@ class TestGridification:
result = db.Grid.gridify(city=city, side_length=side_length)
assert isinstance(result, db.Grid)
assert len(result.pixels) == 0 # noqa:WPS507
assert len(result.pixels) == 0
@pytest.mark.no_cover
def test_no_pixel_with_one_address_too_far_west(self, city, order, addresses_mock):
@ -174,7 +174,7 @@ class TestGridification:
result = db.Grid.gridify(city=city, side_length=side_length)
assert isinstance(result, db.Grid)
assert len(result.pixels) == 0 # noqa:WPS507
assert len(result.pixels) == 0
@pytest.mark.no_cover
def test_two_pixels_with_two_addresses(self, city, make_address, addresses_mock):
@ -206,7 +206,7 @@ class TestGridification:
@pytest.mark.db
@pytest.mark.no_cover
@pytest.mark.parametrize('side_length', [250, 500, 1_000, 2_000, 4_000, 8_000])
def test_make_random_grids( # noqa:WPS211,WPS218
def test_make_random_grids(
self,
db_session,
city,

View file

@ -423,7 +423,7 @@ class TestConstraints:
'left_pickup_at',
],
)
def test_unset_timestamp_column_not_marked_as_uncorrected( # noqa:WPS213
def test_unset_timestamp_column_not_marked_as_uncorrected(
self,
db_session,
order,
@ -507,7 +507,7 @@ class TestConstraints:
'delivery_at',
],
)
def test_set_timestamp_column_is_not_unmarked( # noqa:WPS213
def test_set_timestamp_column_is_not_unmarked(
self,
db_session,
order,
@ -860,14 +860,14 @@ class TestProperties:
assert result > dt.timedelta(0)
def test_scheduled_pickup_at_no_restaurant_notified(self, order): # noqa:WPS118
def test_scheduled_pickup_at_no_restaurant_notified(self, order):
"""Test `Order.scheduled_pickup_at` property."""
order.restaurant_notified_at = None
with pytest.raises(RuntimeError, match='not set'):
int(order.scheduled_pickup_at)
def test_scheduled_pickup_at_no_est_prep_duration(self, order): # noqa:WPS118
def test_scheduled_pickup_at_no_est_prep_duration(self, order):
"""Test `Order.scheduled_pickup_at` property."""
order.estimated_prep_duration = None
@ -952,7 +952,7 @@ class TestProperties:
assert bool(result) is False
def test_time_to_delivery_no_reached_delivery_at(self, order): # noqa:WPS118
def test_time_to_delivery_no_reached_delivery_at(self, order):
"""Test `Order.time_to_delivery` property."""
order.reached_delivery_at = None
@ -972,7 +972,7 @@ class TestProperties:
assert result > dt.timedelta(0)
def test_time_at_delivery_no_reached_delivery_at(self, order): # noqa:WPS118
def test_time_at_delivery_no_reached_delivery_at(self, order):
"""Test `Order.time_at_delivery` property."""
order.reached_delivery_at = None
@ -1083,7 +1083,7 @@ class TestProperties:
@pytest.mark.db
@pytest.mark.no_cover
def test_make_random_orders( # noqa:C901,WPS211,WPS213
def test_make_random_orders( # noqa:C901
db_session,
make_address,
make_courier,
@ -1096,7 +1096,7 @@ def test_make_random_orders( # noqa:C901,WPS211,WPS213
and `Order` objects adhere to the database constraints.
""" # noqa:D202
# Generate a large number of `Order`s to obtain a large variance of data.
for _ in range(1_000): # noqa:WPS122
for _ in range(1_000):
# Ad-hoc `Order`s are far more common than pre-orders.
scheduled = random.choice([True, False, False, False, False])

View file

@ -122,7 +122,7 @@ class TestProperties:
"""A `Mock` whose `.return_value` is `[restaurant]`."""
mock = mocker.Mock()
query = ( # noqa:ECE001
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501,WPS219
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
)
query.return_value = [restaurant]
monkeypatch.setattr(db, 'session', mock)

View file

@ -98,7 +98,7 @@ class TestSpecialMethods:
def test_compare_utm_coordinates_to_themselves(self, location):
"""Test `Location.__eq__()`."""
result = location == location # noqa:WPS312
result = location == location
assert result is True

View file

@ -221,7 +221,7 @@ class TestValidArguments:
@pytest.mark.parametrize('jl', [None, 1])
@pytest.mark.parametrize('ni', [2, 3])
@pytest.mark.parametrize('no', [0, 1])
def test_decompose_time_series_with_no_demand( # noqa:WPS211,WPS216
def test_decompose_time_series_with_no_demand(
self,
vertical_no_demand,
nt,
@ -233,7 +233,7 @@ class TestValidArguments:
jt,
jl,
ni,
no, # noqa:WPS110
no,
):
"""Decomposing a time series with no demand ...
@ -252,7 +252,7 @@ class TestValidArguments:
jt=jt,
jl=jl,
ni=ni,
no=no, # noqa:WPS110
no=no,
)
result = decomposed.sum().sum()

View file

@ -136,7 +136,7 @@ class TestGenericForecastingModelProperties:
@pytest.mark.db
@pytest.mark.r
def test_make_forecast( # noqa:WPS211
def test_make_forecast(
self,
db_session,
model_cls,
@ -160,7 +160,7 @@ class TestGenericForecastingModelProperties:
@pytest.mark.db
@pytest.mark.r
def test_make_forecast_is_cached( # noqa:WPS211
def test_make_forecast_is_cached(
self,
db_session,
model_cls,

View file

@ -27,7 +27,7 @@ class TestAggregateOrders:
"""
mock = mocker.Mock()
query = ( # noqa:ECE001
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501,WPS219
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
)
monkeypatch.setattr(db, 'session', mock)
@ -54,7 +54,7 @@ class TestAggregateOrders:
def test_no_orders(self, db_session, one_pixel_grid, restaurant):
"""Edge case that does not occur for real-life data."""
db_session.commit()
assert len(restaurant.orders) == 0 # noqa:WPS507 sanity check
assert len(restaurant.orders) == 0 # sanity check
oh = timify.OrderHistory(
grid=one_pixel_grid,
@ -63,7 +63,7 @@ class TestAggregateOrders:
result = oh.aggregate_orders()
assert len(result) == 0 # noqa:WPS507
assert len(result) == 0
def test_evenly_distributed_ad_hoc_orders(
self,
@ -99,7 +99,7 @@ class TestAggregateOrders:
assert result['n_orders'].max() == 1
assert result['n_orders'].sum() == 12
def test_evenly_distributed_ad_hoc_orders_with_no_demand_late( # noqa:WPS218
def test_evenly_distributed_ad_hoc_orders_with_no_demand_late(
self,
db_session,
one_pixel_grid,
@ -212,7 +212,7 @@ class TestAggregateOrders:
assert result['n_orders'].max() == 1
assert result['n_orders'].sum() == 1
def test_evenly_distributed_ad_hoc_orders_with_half_hour_time_steps( # noqa:WPS218
def test_evenly_distributed_ad_hoc_orders_with_half_hour_time_steps(
self,
db_session,
one_pixel_grid,
@ -273,7 +273,7 @@ class TestAggregateOrders:
db_session.add(order)
# Create one order every other hour and 6 orders in total.
for hour in range(11, 23, 2): # noqa:WPS440
for hour in range(11, 23, 2):
order = make_order(
scheduled=False,
restaurant=restaurant,
@ -281,7 +281,7 @@ class TestAggregateOrders:
test_config.YEAR,
test_config.MONTH,
test_config.DAY + 1,
hour, # noqa:WPS441
hour,
11,
),
)
@ -305,7 +305,7 @@ class TestAggregateOrders:
assert result['n_orders'].sum() == 18
@pytest.fixture
def two_pixel_grid( # noqa:WPS211
def two_pixel_grid(
self,
db_session,
city,
@ -336,7 +336,7 @@ class TestAggregateOrders:
return grid
def test_two_pixels_with_shifted_orders( # noqa:WPS218
def test_two_pixels_with_shifted_orders(
self,
db_session,
two_pixel_grid,
@ -361,7 +361,7 @@ class TestAggregateOrders:
db_session.add(order)
# Create two orders per hour for `restaurant2`.
for hour in range(11, 23): # noqa:WPS440
for hour in range(11, 23):
order = make_order(
scheduled=False,
restaurant=restaurant2,
@ -369,7 +369,7 @@ class TestAggregateOrders:
test_config.YEAR,
test_config.MONTH,
test_config.DAY,
hour, # noqa:WPS441
hour,
13,
),
)
@ -382,7 +382,7 @@ class TestAggregateOrders:
test_config.YEAR,
test_config.MONTH,
test_config.DAY,
hour, # noqa:WPS441
hour,
14,
),
)

View file

@ -119,7 +119,7 @@ class TestMakeHorizontalTimeSeries:
train_horizon=train_horizon,
)
_, frequency, _ = result # noqa:WPS434
_, frequency, _ = result
assert frequency == 7
@ -243,7 +243,7 @@ class TestMakeVerticalTimeSeries:
train_horizon=train_horizon,
)
_, frequency, _ = result # noqa:WPS434
_, frequency, _ = result
n_daily_time_steps = (
60
@ -423,7 +423,7 @@ class TestMakeRealTimeTimeSeries:
train_horizon=train_horizon,
)
_, frequency, _ = result # noqa:WPS434
_, frequency, _ = result
n_daily_time_steps = (
60

View file

@ -38,7 +38,7 @@ def test_database_uri_set(env, monkeypatch):
warnings.simplefilter('always')
configuration.make_config(env)
assert len(record) == 0 # noqa:WPS441,WPS507
assert len(record) == 0
@pytest.mark.parametrize('env', envs)
@ -56,7 +56,7 @@ def test_no_database_uri_set_with_testing_env_var(env, monkeypatch):
warnings.simplefilter('always')
configuration.make_config(env)
assert len(record) == 0 # noqa:WPS441,WPS507
assert len(record) == 0
@pytest.mark.parametrize('env', envs)
@ -87,7 +87,7 @@ def test_r_libs_path_set(env, monkeypatch):
warnings.simplefilter('always')
configuration.make_config(env)
assert len(record) == 0 # noqa:WPS441,WPS507
assert len(record) == 0
@pytest.mark.parametrize('env', envs)
@ -107,7 +107,7 @@ def test_no_r_libs_path_set_with_testing_env_var(env, monkeypatch):
warnings.simplefilter('always')
configuration.make_config(env)
assert len(record) == 0 # noqa:WPS441,WPS507
assert len(record) == 0
@pytest.mark.parametrize('env', envs)

View file

@ -14,6 +14,6 @@ def test_r_packages_installed():
in the "research/r_dependencies.ipynb" notebook or
in the GitHub Actions CI.
"""
from velofy import init_r # noqa:WPS433
from velofy import init_r
assert init_r is not None

View file

@ -23,7 +23,7 @@ class TestPEP404Compliance:
@pytest.fixture
def parsed_version(self) -> str:
"""The packaged version."""
return pkg_version.Version(velofy.__version__) # noqa:WPS609
return pkg_version.Version(velofy.__version__)
def test_parsed_version_has_no_epoch(self, parsed_version):
"""PEP440 compliant subset of semantic versioning: no epoch."""
@ -39,7 +39,7 @@ class TestPEP404Compliance:
def test_parsed_version_is_all_public(self, parsed_version):
"""PEP440 compliant subset of semantic versioning: all public parts."""
assert parsed_version.public == velofy.__version__ # noqa:WPS609
assert parsed_version.public == velofy.__version__
class TestSemanticVersioning:
@ -51,7 +51,7 @@ class TestSemanticVersioning:
def test_version_is_semantic(self):
"""Packaged version follows semantic versioning."""
result = self.version_pattern.fullmatch(velofy.__version__) # noqa:WPS609
result = self.version_pattern.fullmatch(velofy.__version__)
assert result is not None