diff --git a/noxfile.py b/noxfile.py index 3a93a33..45adbbc 100644 --- a/noxfile.py +++ b/noxfile.py @@ -195,6 +195,7 @@ def lint_code(session: Session) -> None: "flake8-quotes", "flake8-sfs", "flake8-todos", + "flake8-unused-arguments", "isort", # TODO: See comment on `mypy` below # 'mypy', diff --git a/pyproject.toml b/pyproject.toml index 6950c44..af47ef8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,6 +104,7 @@ dev = [ "flake8-quotes (>=3.4.0,<4.0.0)", "flake8-sfs (>=1.0.1,<2.0.0)", "flake8-todos (>=0.3.1,<0.4.0)", + "flake8-unused-arguments (>=0.0.14,<0.1.0)", "mypy (>=2.4.1,<3.0.0)", ] @@ -228,6 +229,8 @@ select = [ "SFS", # flake8-todos => unify TODOs "T00", + # flake8-unused-arguments => declared function arguments must be used + "U100", ] # By default, flake8 ignores some errors. @@ -289,6 +292,8 @@ avoid-escape = true docstring-quotes = "double" inline-quotes = "double" multiline-quotes = "double" +# flake8-unused-arguments +unused-arguments-ignore-abstract-functions = true # ============================== # flake8-pytest-style's settings diff --git a/src/velofy/init_r.py b/src/velofy/init_r.py index f9c2571..29b1106 100644 --- a/src/velofy/init_r.py +++ b/src/velofy/init_r.py @@ -13,8 +13,8 @@ from rpy2.robjects import packages as rpackages # Suppress R's messages to stdout and stderr. # Source: https://stackoverflow.com/a/63220287 -rcallbacks.consolewrite_print = lambda msg: None # pragma: no cover -rcallbacks.consolewrite_warnerror = lambda msg: None # pragma: no cover +rcallbacks.consolewrite_print = lambda _msg: None # pragma: no cover +rcallbacks.consolewrite_warnerror = lambda _msg: None # pragma: no cover # For clarity and convenience, re-raise the error that results from missing R diff --git a/tests/db/test_addresses_addresses.py b/tests/db/test_addresses_addresses.py index 42cb93d..d36c89f 100644 --- a/tests/db/test_addresses_addresses.py +++ b/tests/db/test_addresses_addresses.py @@ -247,7 +247,7 @@ class TestFromAddresses: assert db_session.query(db.Path).count() == 1 @pytest.mark.usefixtures("_prepare_db") - def test_structure_of_return_value(self, db_session, address, another_address): + def test_structure_of_return_value(self, address, another_address): """Test instantiation of a new `Path` instance.""" results = db.Path.from_addresses(address, another_address) @@ -256,7 +256,6 @@ class TestFromAddresses: @pytest.mark.usefixtures("_prepare_db") def test_instances_must_have_air_distance( self, - db_session, address, another_address, ): @@ -270,7 +269,6 @@ class TestFromAddresses: @pytest.mark.usefixtures("_prepare_db") def test_do_not_sync_instances_with_google_maps( self, - db_session, address, another_address, ): @@ -285,7 +283,6 @@ class TestFromAddresses: @pytest.mark.usefixtures("_prepare_db") def test_sync_instances_with_google_maps( self, - db_session, address, another_address, monkeypatch, @@ -306,21 +303,21 @@ class TestFromAddresses: assert result.bicycle_duration is not None @pytest.mark.usefixtures("_prepare_db") - def test_one_path_for_two_addresses(self, db_session, address, another_address): + def test_one_path_for_two_addresses(self, address, another_address): """Test instantiation of a new `Path` instance.""" result = len(db.Path.from_addresses(address, another_address)) assert result == 1 @pytest.mark.usefixtures("_prepare_db") - def test_two_paths_for_three_addresses(self, db_session, make_address): + def test_two_paths_for_three_addresses(self, make_address): """Test instantiation of a new `Path` instance.""" result = len(db.Path.from_addresses(*[make_address() for _ in range(3)])) assert result == 3 @pytest.mark.usefixtures("_prepare_db") - def test_six_paths_for_four_addresses(self, db_session, make_address): + def test_six_paths_for_four_addresses(self, make_address): """Test instantiation of a new `Path` instance.""" result = len(db.Path.from_addresses(*[make_address() for _ in range(4)])) @@ -359,7 +356,7 @@ class TestFromAddresses: assert db_session.query(db.Path).count() == 1 @pytest.mark.usefixtures("_prepare_db") - def test_structure_of_return_value_from_order(self, db_session, order): + def test_structure_of_return_value_from_order(self, order): """Test instantiation of a new `Path` instance.""" result = db.Path.from_order(order) @@ -368,7 +365,6 @@ class TestFromAddresses: @pytest.mark.usefixtures("_prepare_db") def test_sync_instance_from_order_with_google_maps( self, - db_session, order, monkeypatch, ): @@ -652,8 +648,8 @@ class TestSyncWithGoogleMaps: monkeypatch.setattr(googlemaps.Client, "directions", directions) - @pytest.mark.usefixtures("_fake_google_api") - def test_sync_instances_with_google_maps(self, db_session, path): + @pytest.mark.usefixtures("_fake_google_api", "db_session") + def test_sync_instances_with_google_maps(self, path): """Call the method for a `Path` object without Google data.""" path.bicycle_distance = None path.bicycle_duration = None @@ -665,8 +661,8 @@ class TestSyncWithGoogleMaps: assert path.bicycle_duration == 596 assert path._directions is not None - @pytest.mark.usefixtures("_fake_google_api") - def test_repeated_sync_instances_with_google_maps(self, db_session, path): + @pytest.mark.usefixtures("_fake_google_api", "db_session") + def test_repeated_sync_instances_with_google_maps(self, path): """Call the method for a `Path` object with Google data. That call should immediately return without changing any data. diff --git a/tests/forecasts/test_models.py b/tests/forecasts/test_models.py index 1d62f73..f741ba1 100644 --- a/tests/forecasts/test_models.py +++ b/tests/forecasts/test_models.py @@ -136,9 +136,9 @@ class TestGenericForecastingModelProperties: @pytest.mark.db @pytest.mark.r + @pytest.mark.usefixtures("db_session") def test_make_forecast( self, - db_session, model_cls, order_history, pixel, diff --git a/tests/forecasts/timify/test_order_history.py b/tests/forecasts/timify/test_order_history.py index 001dcdc..c122628 100644 --- a/tests/forecasts/timify/test_order_history.py +++ b/tests/forecasts/timify/test_order_history.py @@ -70,7 +70,7 @@ class TestMethods: assert result == test_config.START - def test_first_order_at_non_existing_pixel(self, order_history, good_pixel_id): + def test_first_order_at_non_existing_pixel(self, order_history): """Test `OrderHistory.first_order_at()` with bad input.""" with pytest.raises( LookupError, @@ -85,7 +85,7 @@ class TestMethods: one_time_step = dt.timedelta(minutes=test_config.LONG_TIME_STEP) assert result == test_config.END - one_time_step - def test_last_order_at_non_existing_pixel(self, order_history, good_pixel_id): + def test_last_order_at_non_existing_pixel(self, order_history): """Test `OrderHistory.last_order_at()` with bad input.""" with pytest.raises( LookupError, diff --git a/uv.lock b/uv.lock index 6f2d59b..d184d4b 100644 --- a/uv.lock +++ b/uv.lock @@ -1055,6 +1055,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ba/8e/805907f920d171eda033ac825d23595072a1c04dd716106c8bc8ec9eec9e/flake8_todos-0.3.1-py3-none-any.whl", hash = "sha256:0b4faca80bec49be7bf8e5dd46eec12f619e09cecac8a84a87775272300222b2", size = 7358, upload-time = "2024-02-09T08:50:43.66Z" }, ] +[[package]] +name = "flake8-unused-arguments" +version = "0.0.14" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/1b/6a/12e072814ac64c4ed18c039738d97e7326df1352f696f16872aa0cea482c/flake8_unused_arguments-0.0.14.tar.gz", hash = "sha256:5b6cac6ecb325c0d5460edc6c52e2861c146eca03ddedc36dcb32beafeacbbec", size = 5514, upload-time = "2025-10-27T22:22:55.946Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b3/0b/1d658aca231a3e4b3c0b9e7fed71ced551cbfd955a41cfd32b221b396edc/flake8_unused_arguments-0.0.14-py3-none-any.whl", hash = "sha256:6c0b7ce7236a156f4bd90adec67ad0e5d0139efcd15c2a1fc0fb3a6ffd7e435e", size = 6190, upload-time = "2025-10-27T22:22:54.888Z" }, +] + [[package]] name = "folium" version = "1.0.0" @@ -3707,6 +3719,7 @@ dev = [ { name = "flake8-quotes" }, { name = "flake8-sfs" }, { name = "flake8-todos" }, + { name = "flake8-unused-arguments" }, { name = "isort" }, { name = "mypy" }, { name = "nox" }, @@ -3768,6 +3781,7 @@ dev = [ { name = "flake8-quotes", specifier = ">=3.4.0,<4.0.0" }, { name = "flake8-sfs", specifier = ">=1.0.1,<2.0.0" }, { name = "flake8-todos", specifier = ">=0.3.1,<0.4.0" }, + { name = "flake8-unused-arguments", specifier = ">=0.0.14,<0.1.0" }, { name = "isort", specifier = ">=9.0.2,<10.0.0" }, { name = "mypy", specifier = ">=2.4.1,<3.0.0" }, { name = "nox", specifier = ">=2026.10.20" },