From b41d10f2e174ec36c415de8185cbdbe8bef99b4e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:33:17 +0000 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#9316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.0...v0.5.6) - [github.com/pre-commit/mirrors-mypy: v1.10.1 → v1.11.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.1...v1.11.1) * downgrade mypy * use `is` to compare types * [skip-rtd] * manually update all hooks [skip-rtd] --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Justus Magin Co-authored-by: Justus Magin --- .pre-commit-config.yaml | 8 ++++---- xarray/coding/cftime_offsets.py | 8 ++++---- xarray/testing/assertions.py | 6 +++--- xarray/tests/test_distributed.py | 2 +- xarray/tests/test_plot.py | 2 +- xarray/tests/test_variable.py | 30 +++++++++++++++--------------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 948455ebca2..57f8b9e86f5 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.5.0' + rev: 'v0.6.2' 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.4.2 + rev: 24.8.0 hooks: - id: black-jupyter - repo: https://github.com/keewis/blackdoc @@ -27,10 +27,10 @@ repos: hooks: - id: blackdoc exclude: "generate_aggregations.py" - additional_dependencies: ["black==24.4.2"] + additional_dependencies: ["black==24.8.0"] - id: blackdoc-autoupdate-black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.11.2 hooks: - id: mypy # Copied from setup.cfg diff --git a/xarray/coding/cftime_offsets.py b/xarray/coding/cftime_offsets.py index ad2f55e585f..f7bed2c13ef 100644 --- a/xarray/coding/cftime_offsets.py +++ b/xarray/coding/cftime_offsets.py @@ -145,7 +145,7 @@ def __sub__(self, other): if isinstance(other, cftime.datetime): raise TypeError("Cannot subtract a cftime.datetime from a time offset.") - elif type(other) == type(self): + elif type(other) is type(self): return type(self)(self.n - other.n) else: return NotImplemented @@ -165,7 +165,7 @@ def __radd__(self, other): return self.__add__(other) def __rsub__(self, other): - if isinstance(other, BaseCFTimeOffset) and type(self) != type(other): + if isinstance(other, BaseCFTimeOffset) and type(self) is not type(other): raise TypeError("Cannot subtract cftime offsets of differing types") return -self + other @@ -462,7 +462,7 @@ def __sub__(self, other: Self) -> Self: if isinstance(other, cftime.datetime): raise TypeError("Cannot subtract cftime.datetime from offset.") - if type(other) == type(self) and other.month == self.month: + if type(other) is type(self) and other.month == self.month: return type(self)(self.n - other.n, month=self.month) return NotImplemented @@ -548,7 +548,7 @@ def __sub__(self, other): if isinstance(other, cftime.datetime): raise TypeError("Cannot subtract cftime.datetime from offset.") - elif type(other) == type(self) and other.month == self.month: + elif type(other) is type(self) and other.month == self.month: return type(self)(self.n - other.n, month=self.month) else: return NotImplemented diff --git a/xarray/testing/assertions.py b/xarray/testing/assertions.py index 5bc9c8c1016..3dec6a25616 100644 --- a/xarray/testing/assertions.py +++ b/xarray/testing/assertions.py @@ -149,7 +149,7 @@ def assert_equal(a, b, from_root=True, check_dim_order: bool = True): """ __tracebackhide__ = True assert ( - type(a) == type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates) + type(a) is type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates) ) b = maybe_transpose_dims(a, b, check_dim_order) if isinstance(a, Variable | DataArray): @@ -206,7 +206,7 @@ def assert_identical(a, b, from_root=True): """ __tracebackhide__ = True assert ( - type(a) == type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates) + type(a) is type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates) ) if isinstance(a, Variable): assert a.identical(b), formatting.diff_array_repr(a, b, "identical") @@ -260,7 +260,7 @@ def assert_allclose( assert_identical, assert_equal, numpy.testing.assert_allclose """ __tracebackhide__ = True - assert type(a) == type(b) + assert type(a) is type(b) b = maybe_transpose_dims(a, b, check_dim_order) equiv = functools.partial( diff --git a/xarray/tests/test_distributed.py b/xarray/tests/test_distributed.py index d223bce2098..ca37fbd3d99 100644 --- a/xarray/tests/test_distributed.py +++ b/xarray/tests/test_distributed.py @@ -295,4 +295,4 @@ def f(x, lock=None): await c.gather(futures) lock2 = pickle.loads(pickle.dumps(lock)) - assert type(lock) == type(lock2) + assert type(lock) is type(lock2) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 680a98a6500..3ebaeff712b 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -1177,7 +1177,7 @@ def setUp(self): @pytest.mark.slow def test_recover_from_seaborn_jet_exception(self) -> None: pal = _color_palette("jet", 4) - assert type(pal) == np.ndarray + assert type(pal) is np.ndarray assert len(pal) == 4 @pytest.mark.slow diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index d1d5d5ada55..a1d8994a736 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -1268,38 +1268,38 @@ def test_detect_indexer_type(self): v = Variable(["x", "y"], data) _, ind, _ = v._broadcast_indexes((0, 1)) - assert type(ind) == indexing.BasicIndexer + assert type(ind) is indexing.BasicIndexer _, ind, _ = v._broadcast_indexes((0, slice(0, 8, 2))) - assert type(ind) == indexing.BasicIndexer + assert type(ind) is indexing.BasicIndexer _, ind, _ = v._broadcast_indexes((0, [0, 1])) - assert type(ind) == indexing.OuterIndexer + assert type(ind) is indexing.OuterIndexer _, ind, _ = v._broadcast_indexes(([0, 1], 1)) - assert type(ind) == indexing.OuterIndexer + assert type(ind) is indexing.OuterIndexer _, ind, _ = v._broadcast_indexes(([0, 1], [1, 2])) - assert type(ind) == indexing.OuterIndexer + assert type(ind) is indexing.OuterIndexer _, ind, _ = v._broadcast_indexes(([0, 1], slice(0, 8, 2))) - assert type(ind) == indexing.OuterIndexer + assert type(ind) is indexing.OuterIndexer vind = Variable(("a",), [0, 1]) _, ind, _ = v._broadcast_indexes((vind, slice(0, 8, 2))) - assert type(ind) == indexing.OuterIndexer + assert type(ind) is indexing.OuterIndexer vind = Variable(("y",), [0, 1]) _, ind, _ = v._broadcast_indexes((vind, 3)) - assert type(ind) == indexing.OuterIndexer + assert type(ind) is indexing.OuterIndexer vind = Variable(("a",), [0, 1]) _, ind, _ = v._broadcast_indexes((vind, vind)) - assert type(ind) == indexing.VectorizedIndexer + assert type(ind) is indexing.VectorizedIndexer vind = Variable(("a", "b"), [[0, 2], [1, 3]]) _, ind, _ = v._broadcast_indexes((vind, 3)) - assert type(ind) == indexing.VectorizedIndexer + assert type(ind) is indexing.VectorizedIndexer def test_indexer_type(self): # GH:issue:1688. Wrong indexer type induces NotImplementedError @@ -2587,7 +2587,7 @@ def test_converted_types(self): for input_array in [[[0, 1, 2]], pd.DataFrame([[0, 1, 2]])]: actual = as_compatible_data(input_array) assert_array_equal(np.asarray(input_array), actual) - assert np.ndarray == type(actual) + assert np.ndarray is type(actual) assert np.asarray(input_array).dtype == actual.dtype def test_masked_array(self): @@ -2622,26 +2622,26 @@ def test_datetime(self): expected = np.datetime64("2000-01-01") actual = as_compatible_data(expected) assert expected == actual - assert np.ndarray == type(actual) + assert np.ndarray is type(actual) assert np.dtype("datetime64[ns]") == actual.dtype expected = np.array([np.datetime64("2000-01-01")]) actual = as_compatible_data(expected) assert np.asarray(expected) == actual - assert np.ndarray == type(actual) + assert np.ndarray is type(actual) assert np.dtype("datetime64[ns]") == actual.dtype expected = np.array([np.datetime64("2000-01-01", "ns")]) actual = as_compatible_data(expected) assert np.asarray(expected) == actual - assert np.ndarray == type(actual) + assert np.ndarray is type(actual) assert np.dtype("datetime64[ns]") == actual.dtype assert expected is source_ndarray(np.asarray(actual)) expected = np.datetime64("2000-01-01", "ns") actual = as_compatible_data(datetime(2000, 1, 1)) assert np.asarray(expected) == actual - assert np.ndarray == type(actual) + assert np.ndarray is type(actual) assert np.dtype("datetime64[ns]") == actual.dtype def test_tz_datetime(self) -> None: