From 48a0440694fd0832e066c8df313f6e7199d08cb0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:31:54 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.12 → v0.13.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.12...v0.13.0) - [github.com/pre-commit/mirrors-mypy: v1.17.1 → v1.18.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.17.1...v1.18.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7165232ce..17b19b271 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,13 +5,13 @@ repos: - id: check-merge-conflict - id: debug-statements - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.12 + rev: v0.13.0 hooks: - id: ruff-check # Run the linter. args: [--fix, --exit-non-zero-on-fix] - id: ruff-format # Run the formatter. - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.17.1" + rev: "v1.18.1" hooks: - id: mypy additional_dependencies: [types-jsonschema, xarray, types-tabulate, numpy] From cd8e3a54f1ef9bffc3f9a33997247f6610aefb6c Mon Sep 17 00:00:00 2001 From: David Orme Date: Mon, 22 Sep 2025 11:04:02 +0100 Subject: [PATCH 2/2] Fixing new ruff-check issues --- tests/core/data/example_netcdf_generator.py | 2 -- tests/core/test_variables.py | 14 +++++++------- tests/models/animals/test_animal_cohorts.py | 2 +- tests/models/hydrology/test_hydrology_model.py | 2 +- tests/models/hydrology/test_hydrology_tools.py | 4 ++-- tests/models/plants/test_exporter.py | 4 ++-- virtual_ecosystem/models/abiotic/wind.py | 1 - 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/core/data/example_netcdf_generator.py b/tests/core/data/example_netcdf_generator.py index 04264c053..1d1bb4a1b 100644 --- a/tests/core/data/example_netcdf_generator.py +++ b/tests/core/data/example_netcdf_generator.py @@ -23,8 +23,6 @@ def generate_files() -> None: x = x_off + x_idx * res + res / 2 y = y_off + y_idx * res + res / 2 - xx, yy = np.meshgrid(x, y) - # Cell IDs cell_id = np.arange(x_n * y_n) diff --git a/tests/core/test_variables.py b/tests/core/test_variables.py index 8798718aa..5b17c8697 100644 --- a/tests/core/test_variables.py +++ b/tests/core/test_variables.py @@ -176,7 +176,7 @@ class TestModel: model_name = "TestModel" vars_populated_by_init = ("test_var",) - with pytest.raises(ValueError, match="not in the known variables registry."): + with pytest.raises(ValueError, match=r"not in the known variables registry."): variables._collect_vars_populated_by_init([TestModel]) variables.Variable( @@ -207,7 +207,7 @@ class TestModel: vars_populated_by_first_update = ("test_var",) vars_populated_by_init = ("test_var",) - with pytest.raises(ValueError, match="not in the known variables registry."): + with pytest.raises(ValueError, match=r"not in the known variables registry."): variables._collect_vars_populated_by_first_update([TestModel]) variables.Variable( @@ -245,7 +245,7 @@ class TestModel: model_name = "TestModel" vars_updated = ("test_var",) - with pytest.raises(ValueError, match="not in the known variables registry."): + with pytest.raises(ValueError, match=r"not in the known variables registry."): variables._collect_updated_by_vars([TestModel]) var = variables.Variable( @@ -282,7 +282,7 @@ class TestModel: model_name = "TestModel" vars_required_for_update = ("test_var",) - with pytest.raises(ValueError, match="not in the known variables registry."): + with pytest.raises(ValueError, match=r"not in the known variables registry."): variables._collect_vars_required_for_update([TestModel]) var = variables.Variable( @@ -313,7 +313,7 @@ class TestModel: model_name = "TestModel" vars_required_for_init = ("test_var",) - with pytest.raises(ValueError, match="not in the known variables registry."): + with pytest.raises(ValueError, match=r"not in the known variables registry."): variables._collect_vars_required_for_init([TestModel]) var = variables.Variable( @@ -416,7 +416,7 @@ def test_get_variable(known_variables, run_variables): """Test the get_variable function.""" from virtual_ecosystem.core import variables - with pytest.raises(KeyError, match="not a known variable."): + with pytest.raises(KeyError, match=r"not a known variable."): variables.get_variable("test_var") var = variables.Variable( @@ -500,7 +500,7 @@ def test_get_model_order(run_variables): # Test wrong stage with pytest.raises( - ConfigurationError, match="Stage must be either 'init' or 'update'." + ConfigurationError, match=r"Stage must be either 'init' or 'update'." ): variables.get_model_order("wrong_stage") diff --git a/tests/models/animals/test_animal_cohorts.py b/tests/models/animals/test_animal_cohorts.py index 64c46a0cc..dc40bd5b9 100644 --- a/tests/models/animals/test_animal_cohorts.py +++ b/tests/models/animals/test_animal_cohorts.py @@ -464,7 +464,7 @@ def test_die_individual( # Handle zero-death cases separately if number_of_deaths == 0: with pytest.raises( - ValueError, match="Number of deaths must be a positive integer." + ValueError, match=r"Number of deaths must be a positive integer." ): herbivore_cohort_instance.die_individual(number_of_deaths, []) return diff --git a/tests/models/hydrology/test_hydrology_model.py b/tests/models/hydrology/test_hydrology_model.py index 3efbde429..b1f62e111 100644 --- a/tests/models/hydrology/test_hydrology_model.py +++ b/tests/models/hydrology/test_hydrology_model.py @@ -204,7 +204,7 @@ def test_generate_hydrology_model( mock_setup.assert_called_once() # Check arguments passed to _setup - called_args, called_kwargs = mock_setup.call_args + _called_args, called_kwargs = mock_setup.call_args assert ( called_kwargs["initial_soil_moisture"] == config["hydrology"]["initial_soil_moisture"] diff --git a/tests/models/hydrology/test_hydrology_tools.py b/tests/models/hydrology/test_hydrology_tools.py index 7e235124e..b5fdd3d5e 100644 --- a/tests/models/hydrology/test_hydrology_tools.py +++ b/tests/models/hydrology/test_hydrology_tools.py @@ -173,8 +173,8 @@ def test_check_precipitation_surface_raises_error(): with pytest.raises( ValueError, - match="Surface precipitation should not be negative! Consider checking that the" - " canopy water balance is correct.", + match=r"Surface precipitation should not be negative! " + r"Consider checking that the canopy water balance is correct.", ): check_precipitation_surface(test_array) diff --git a/tests/models/plants/test_exporter.py b/tests/models/plants/test_exporter.py index 495b2f225..550ca2e79 100644 --- a/tests/models/plants/test_exporter.py +++ b/tests/models/plants/test_exporter.py @@ -326,7 +326,7 @@ def test_CommunityDataExporter_dump_cohort_data( ) # First dump in write mode with no allocations: expected behaviour in setup - communities, canopies, stem_allocations = fixture_exporter_components + communities, canopies, _stem_allocations = fixture_exporter_components exporter._dump_cohort_data( communities=communities, canopies=canopies, @@ -639,7 +639,7 @@ def test_CommunityDataExporter_through_config( assert exporter._write_header # First dump in write mode with no allocations: expected behaviour in setup - communities, canopies, stem_allocations = fixture_exporter_components + communities, canopies, _stem_allocations = fixture_exporter_components exporter.dump( communities=communities, canopies=canopies, diff --git a/virtual_ecosystem/models/abiotic/wind.py b/virtual_ecosystem/models/abiotic/wind.py index b64425ea3..3fec215e6 100644 --- a/virtual_ecosystem/models/abiotic/wind.py +++ b/virtual_ecosystem/models/abiotic/wind.py @@ -369,7 +369,6 @@ def mix_and_ventilate( # Copy the input to update with mixing input_variable_mixed = input_variable.copy() - n_layers, n_cells = input_variable_mixed.shape # Extract the layer thickness and current value for the canopy layers, excluding the # surface layer and above canopy values