Enable more lint rules #10
9 changed files with 26 additions and 17 deletions
Enable RUF in ruff
commit
c56fe649b7
|
|
@ -265,6 +265,8 @@ select = [
|
|||
# "PL",
|
||||
# flake8-use-pathlib => `pathlib` instead of `os` functions
|
||||
# "PTH",
|
||||
# Ruff-specific rules => Fewer bugs and cleaner code
|
||||
# "RUF",
|
||||
# flake8-self => No access to private members from outside
|
||||
# "SLF",
|
||||
# pyupgrade => Modern syntax for the targeted Python version
|
||||
|
|
@ -559,6 +561,8 @@ select = [
|
|||
"PL",
|
||||
# flake8-use-pathlib => `pathlib` instead of `os` functions
|
||||
"PTH",
|
||||
# Ruff-specific rules => Fewer bugs and cleaner code
|
||||
"RUF",
|
||||
# flake8-self => No access to private members from outside
|
||||
"SLF",
|
||||
# flake8-print => no `print()`
|
||||
|
|
@ -576,11 +580,20 @@ extend-ignore = [
|
|||
"PT023",
|
||||
# An `elif` after a `return` keeps a case distinction together.
|
||||
"RET505",
|
||||
# Some "# noqa" comments are only for `flake8`, which `ruff` cannot know.
|
||||
"RUF100",
|
||||
# TODOs need neither an author nor an issue.
|
||||
"TD002", "TD003",
|
||||
]
|
||||
|
||||
|
||||
# Codes only `flake8` knows, kept in "# noqa" comments
|
||||
external = [
|
||||
"B902",
|
||||
"DOC",
|
||||
]
|
||||
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
|
||||
# Top-levels of a sub-packages are intended to import a lot.
|
||||
|
|
|
|||
|
|
@ -40,19 +40,19 @@ class Config:
|
|||
|
||||
# Side lengths (in meters) for which pixel grids are created.
|
||||
# They are the basis for the aggregated demand forecasts.
|
||||
GRID_SIDE_LENGTHS = [707, 1000, 1414]
|
||||
GRID_SIDE_LENGTHS = (707, 1000, 1414)
|
||||
|
||||
# Time steps (in minutes) used to aggregate the
|
||||
# individual orders into time series.
|
||||
TIME_STEPS = [60]
|
||||
TIME_STEPS = (60,)
|
||||
|
||||
# Training horizons (in full weeks) used to train the forecasting models.
|
||||
# For now, we only use 7 and 8 weeks as that was the best performing in
|
||||
# a previous study (note:4f79e8fa).
|
||||
TRAIN_HORIZONS = [7, 8]
|
||||
TRAIN_HORIZONS = (7, 8)
|
||||
|
||||
# The demand forecasting methods used in the simulations.
|
||||
FORECASTING_METHODS = ["hets", "rtarima"]
|
||||
FORECASTING_METHODS = ("hets", "rtarima")
|
||||
|
||||
# Colors for the visualizations ins `folium`.
|
||||
RESTAURANT_COLOR = "red"
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class Pixel(meta.Base):
|
|||
"""Shortcut to the `.city.map` object."""
|
||||
return self.grid.city.map
|
||||
|
||||
def draw( # noqa:C901,PLR0912
|
||||
def draw(
|
||||
self,
|
||||
*,
|
||||
restaurants: bool = True,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ def test_two_pixels_with_two_addresses(
|
|||
side_length = max(city.total_x // 2, city.total_y // 2) + 1
|
||||
|
||||
# Hack the configuration regarding the grids to be created.
|
||||
monkeypatch.setattr(velofy.config, "GRID_SIDE_LENGTHS", [side_length])
|
||||
monkeypatch.setattr(velofy.config, "GRID_SIDE_LENGTHS", (side_length,))
|
||||
|
||||
result = cli.invoke(gridify.gridify)
|
||||
|
||||
|
|
|
|||
|
|
@ -83,9 +83,7 @@ class TestGridification:
|
|||
all considered `Order.pickup_address` attributes for some orders.
|
||||
"""
|
||||
mock = mocker.Mock()
|
||||
query = (
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
query = mock.query.return_value.join.return_value.filter.return_value.all
|
||||
monkeypatch.setattr(db, "session", mock)
|
||||
|
||||
return query
|
||||
|
|
|
|||
|
|
@ -1150,7 +1150,7 @@ class TestProperties:
|
|||
|
||||
@pytest.mark.db
|
||||
@pytest.mark.no_cover
|
||||
def test_make_random_orders( # noqa:C901
|
||||
def test_make_random_orders(
|
||||
db_session,
|
||||
make_address,
|
||||
make_courier,
|
||||
|
|
|
|||
|
|
@ -121,9 +121,7 @@ class TestProperties:
|
|||
def _restaurants_mock(self, mocker, monkeypatch, restaurant):
|
||||
"""A `Mock` whose `.return_value` is `[restaurant]`."""
|
||||
mock = mocker.Mock()
|
||||
query = (
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
query = mock.query.return_value.join.return_value.filter.return_value.all
|
||||
query.return_value = [restaurant]
|
||||
monkeypatch.setattr(db, "session", mock)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
"""Tests for the `velofy.forecasts.models` sub-package."""
|
||||
|
||||
import typing as t
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
|
||||
|
|
@ -45,7 +47,7 @@ class TestGenericForecastingModelProperties:
|
|||
|
||||
assert isinstance(result, str)
|
||||
|
||||
unique_model_names = set()
|
||||
unique_model_names: t.ClassVar[set[str]] = set()
|
||||
|
||||
def test_each_model_has_a_unique_name(self, model_cls, order_history):
|
||||
"""The `*Model.name` values must be unique across all `*Model`s.
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ class TestAggregateOrders:
|
|||
Note: This fixture also exists in `tests.db.test_grids`.
|
||||
"""
|
||||
mock = mocker.Mock()
|
||||
query = (
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
query = mock.query.return_value.join.return_value.filter.return_value.all
|
||||
monkeypatch.setattr(db_session, "query", mock.query)
|
||||
|
||||
return query
|
||||
|
|
|
|||
Loading…
Reference in a new issue