From da0f2022035c7134fd8e01c080c09eff90721a40 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:27:25 +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.2.0 → v0.3.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.0...v0.3.4) - [github.com/psf/black-pre-commit-mirror: 24.1.1 → 24.3.0](https://github.com/psf/black-pre-commit-mirror/compare/24.1.1...24.3.0) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74d77e2f2ca..9e4cae81070 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,13 +13,13 @@ repos: - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.2.0' + rev: 'v0.3.4' hooks: - id: ruff args: ["--fix", "--show-fixes"] # https://github.com/python/black#version-control-integration - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.1.1 + rev: 24.3.0 hooks: - id: black-jupyter - repo: https://github.com/keewis/blackdoc @@ -30,7 +30,7 @@ repos: additional_dependencies: ["black==24.1.1"] - id: blackdoc-autoupdate-black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.9.0 hooks: - id: mypy # Copied from setup.cfg From 54d02cf8dfb3619c4b4350aae23f3f3582344e7a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:28:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .pre-commit-config.yaml | 2 +- xarray/coding/times.py | 10 +--------- xarray/coding/variables.py | 4 +--- xarray/core/arithmetic.py | 4 ++-- xarray/core/computation.py | 6 +----- xarray/core/formatting.py | 4 ++-- 6 files changed, 8 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e4cae81070..970b2e5e8ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: hooks: - id: blackdoc exclude: "generate_aggregations.py" - additional_dependencies: ["black==24.1.1"] + additional_dependencies: ["black==24.3.0"] - id: blackdoc-autoupdate-black - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.9.0 diff --git a/xarray/coding/times.py b/xarray/coding/times.py index 92bce0abeaa..466e847e003 100644 --- a/xarray/coding/times.py +++ b/xarray/coding/times.py @@ -446,15 +446,7 @@ def format_cftime_datetime(date) -> str: """Converts a cftime.datetime object to a string with the format: YYYY-MM-DD HH:MM:SS.UUUUUU """ - return "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}".format( - date.year, - date.month, - date.day, - date.hour, - date.minute, - date.second, - date.microsecond, - ) + return f"{date.year:04d}-{date.month:02d}-{date.day:02d} {date.hour:02d}:{date.minute:02d}:{date.second:02d}.{date.microsecond:06d}" def infer_timedelta_units(deltas) -> str: diff --git a/xarray/coding/variables.py b/xarray/coding/variables.py index 52cf0fc3656..d31cb6e626a 100644 --- a/xarray/coding/variables.py +++ b/xarray/coding/variables.py @@ -81,9 +81,7 @@ def get_duck_array(self): return self.func(self.array.get_duck_array()) def __repr__(self) -> str: - return "{}({!r}, func={!r}, dtype={!r})".format( - type(self).__name__, self.array, self.func, self.dtype - ) + return f"{type(self).__name__}({self.array!r}, func={self.func!r}, dtype={self.dtype!r})" class NativeEndiannessArray(indexing.ExplicitlyIndexedNDArrayMixin): diff --git a/xarray/core/arithmetic.py b/xarray/core/arithmetic.py index 452c7115b75..734d7b328de 100644 --- a/xarray/core/arithmetic.py +++ b/xarray/core/arithmetic.py @@ -62,10 +62,10 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): if method != "__call__": # TODO: support other methods, e.g., reduce and accumulate. raise NotImplementedError( - "{} method for ufunc {} is not implemented on xarray objects, " + f"{method} method for ufunc {ufunc} is not implemented on xarray objects, " "which currently only support the __call__ method. As an " "alternative, consider explicitly converting xarray objects " - "to NumPy arrays (e.g., with `.values`).".format(method, ufunc) + "to NumPy arrays (e.g., with `.values`)." ) if any(isinstance(o, SupportsArithmetic) for o in out): diff --git a/xarray/core/computation.py b/xarray/core/computation.py index f29f6c4dd35..f09b04b7765 100644 --- a/xarray/core/computation.py +++ b/xarray/core/computation.py @@ -133,11 +133,7 @@ def __ne__(self, other): return not self == other def __repr__(self): - return "{}({!r}, {!r})".format( - type(self).__name__, - list(self.input_core_dims), - list(self.output_core_dims), - ) + return f"{type(self).__name__}({list(self.input_core_dims)!r}, {list(self.output_core_dims)!r})" def __str__(self): lhs = ",".join("({})".format(",".join(dims)) for dims in self.input_core_dims) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index 260dabd9d31..3eed7d02a2e 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -289,8 +289,8 @@ def inline_sparse_repr(array): """Similar to sparse.COO.__repr__, but without the redundant shape/dtype.""" sparse_array_type = array_type("sparse") assert isinstance(array, sparse_array_type), array - return "<{}: nnz={:d}, fill_value={!s}>".format( - type(array).__name__, array.nnz, array.fill_value + return ( + f"<{type(array).__name__}: nnz={array.nnz:d}, fill_value={array.fill_value!s}>" )