From cb01ba526599969932b407a2379403cdbb912fcb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:04:00 +0000 Subject: [PATCH 1/5] [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.4.10 → v0.6.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.6.8) - [github.com/PyCQA/flake8: 7.1.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/7.1.0...7.1.1) - [github.com/asottile/blacken-docs: 1.16.0 → 1.18.0](https://github.com/asottile/blacken-docs/compare/1.16.0...1.18.0) - [github.com/pre-commit/mirrors-mypy: v1.9.0 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.9.0...v1.11.2) - [github.com/numpy/numpydoc: v1.7.0 → v1.8.0](https://github.com/numpy/numpydoc/compare/v1.7.0...v1.8.0) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index feedba5b74..0398f60da2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - id: no-commit-to-branch - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.4.10" + rev: "v0.6.8" hooks: - id: ruff types: [file, python] @@ -45,13 +45,13 @@ repos: additional_dependencies: [tomli] - repo: https://github.com/PyCQA/flake8 - rev: 7.1.0 + rev: 7.1.1 hooks: - id: flake8 types: [file, python] - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 + rev: 1.18.0 hooks: - id: blacken-docs types: [file, rst] @@ -63,7 +63,7 @@ repos: types: [file, python] - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.9.0' + rev: 'v1.11.2' hooks: - id: mypy additional_dependencies: @@ -71,7 +71,7 @@ repos: exclude: 'noxfile\.py|docs/src/conf\.py' - repo: https://github.com/numpy/numpydoc - rev: v1.7.0 + rev: v1.8.0 hooks: - id: numpydoc-validation exclude: "^lib/iris/tests/|docs/gallery_code/" From f83b9d5c1d56cab0d90376db12a19fb10b1df9b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:04:43 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../tests/unit/fileformats/nc_load_rules/actions/__init__.py | 2 +- .../nc_load_rules/actions/test__latlon_dimcoords.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/iris/tests/unit/fileformats/nc_load_rules/actions/__init__.py b/lib/iris/tests/unit/fileformats/nc_load_rules/actions/__init__.py index f768ae3587..7c79740023 100644 --- a/lib/iris/tests/unit/fileformats/nc_load_rules/actions/__init__.py +++ b/lib/iris/tests/unit/fileformats/nc_load_rules/actions/__init__.py @@ -140,7 +140,7 @@ def run_testcase(self, warning_regex=None, **testcase_kwargs): if self.debug_info: print("\nCube:") print(cube) - print("") + print() return cube def _make_testcase_cdl(self, **kwargs): diff --git a/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__latlon_dimcoords.py b/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__latlon_dimcoords.py index fcaa67c308..15401a2ca1 100644 --- a/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__latlon_dimcoords.py +++ b/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__latlon_dimcoords.py @@ -133,9 +133,9 @@ def check_result( self.assertEqual(1, len(cube.coords(dim_coords=True))) (coord,) = coords if self.debug_info: - print("") + print() print("DEBUG : result coord =", coord) - print("") + print() coord_stdname, coord_longname, coord_units, coord_crs = [ getattr(coord, name) From 109ea8117ba3f84d3d0a450b47cc0d3368e8528d Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 3 Oct 2024 15:16:39 +0100 Subject: [PATCH 3/5] Temporarily disable MyPy call-arg errors. --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9e7cf051b0..b849dae9e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -165,6 +165,8 @@ ignore = [ [tool.mypy] # See https://mypy.readthedocs.io/en/stable/config_file.html +# TODO: remove when MyPy fixed (see https://github.com/python/mypy/issues/17166) +disable_error_code = ["call-arg"] enable_error_code = ["ignore-without-code", "truthy-bool"] exclude = [ 'noxfile\.py', @@ -211,7 +213,7 @@ checks = [ "PR01", # Parameters ... not documented "PR02", # Unknown parameters {....} "PR04", # Parameter "...." has no type - "PR07", # Parameter "...." has no description + "PR07", # Parameter "...." has no description "RT01", # No Returns section found "RT03", # Return value has no description ] From 609e19bc4a80bed7f8e819a0598c9ce80670bf12 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 3 Oct 2024 15:19:32 +0100 Subject: [PATCH 4/5] Fix Ruff compliance. --- lib/iris/tests/__init__.py | 4 +--- lib/iris/tests/integration/test_netcdf__loadsaveattrs.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/iris/tests/__init__.py b/lib/iris/tests/__init__.py index 7c6f578a5f..a2824f90c2 100644 --- a/lib/iris/tests/__init__.py +++ b/lib/iris/tests/__init__.py @@ -548,9 +548,7 @@ def assertRepr(self, obj, reference_filename): def _check_same(self, item, reference_path, type_comparison_name="CML"): if self._check_reference_file(reference_path): with open(reference_path, "rb") as reference_fh: - reference = "".join( - part.decode("utf-8") for part in reference_fh.readlines() - ) + reference = "".join(part.decode("utf-8") for part in reference_fh) self._assert_str_same(reference, item, reference_path, type_comparison_name) else: self._ensure_folder(reference_path) diff --git a/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py b/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py index 1eeb5c4f0e..436c9b0a17 100644 --- a/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py +++ b/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py @@ -1022,7 +1022,7 @@ def test_16_localstyle(self, local_attr, origin_style, do_split): expected_result = [expect_global, expect_var] if do_split and origin_style == "input_global": # The result is simply the "other way around" - expected_result = expected_result[::-1] + expected_result = expected_result.reverse() self.check_roundtrip_results(expected_result) @pytest.mark.parametrize("testcase", _MATRIX_TESTCASES[:max_param_attrs]) From 32947f6054d45a49d8cde804e485aecc8be698ec Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 3 Oct 2024 15:33:57 +0100 Subject: [PATCH 5/5] reverse() is an in-place operation. --- lib/iris/tests/integration/test_netcdf__loadsaveattrs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py b/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py index 436c9b0a17..b89477bfe9 100644 --- a/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py +++ b/lib/iris/tests/integration/test_netcdf__loadsaveattrs.py @@ -1022,7 +1022,7 @@ def test_16_localstyle(self, local_attr, origin_style, do_split): expected_result = [expect_global, expect_var] if do_split and origin_style == "input_global": # The result is simply the "other way around" - expected_result = expected_result.reverse() + expected_result.reverse() self.check_roundtrip_results(expected_result) @pytest.mark.parametrize("testcase", _MATRIX_TESTCASES[:max_param_attrs])