Skip to content

Commit 20cde77

Browse files
[pre-commit.ci] pre-commit autoupdate (#9316)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.6](astral-sh/ruff-pre-commit@v0.5.0...v0.5.6) - [github.com/pre-commit/mirrors-mypy: v1.10.1 → v1.11.1](pre-commit/mirrors-mypy@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 <keewis@users.noreply.github.com> Co-authored-by: Justus Magin <keewis@posteo.de>
1 parent 93af904 commit 20cde77

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ repos:
1313
- id: mixed-line-ending
1414
- repo: https://github.com/astral-sh/ruff-pre-commit
1515
# Ruff version.
16-
rev: 'v0.5.0'
16+
rev: 'v0.6.2'
1717
hooks:
1818
- id: ruff
1919
args: ["--fix", "--show-fixes"]
2020
# https://github.com/python/black#version-control-integration
2121
- repo: https://github.com/psf/black-pre-commit-mirror
22-
rev: 24.4.2
22+
rev: 24.8.0
2323
hooks:
2424
- id: black-jupyter
2525
- repo: https://github.com/keewis/blackdoc
2626
rev: v0.3.9
2727
hooks:
2828
- id: blackdoc
2929
exclude: "generate_aggregations.py"
30-
additional_dependencies: ["black==24.4.2"]
30+
additional_dependencies: ["black==24.8.0"]
3131
- id: blackdoc-autoupdate-black
3232
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v1.10.1
33+
rev: v1.11.2
3434
hooks:
3535
- id: mypy
3636
# Copied from setup.cfg

xarray/coding/cftime_offsets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __sub__(self, other):
145145

146146
if isinstance(other, cftime.datetime):
147147
raise TypeError("Cannot subtract a cftime.datetime from a time offset.")
148-
elif type(other) == type(self):
148+
elif type(other) is type(self):
149149
return type(self)(self.n - other.n)
150150
else:
151151
return NotImplemented
@@ -165,7 +165,7 @@ def __radd__(self, other):
165165
return self.__add__(other)
166166

167167
def __rsub__(self, other):
168-
if isinstance(other, BaseCFTimeOffset) and type(self) != type(other):
168+
if isinstance(other, BaseCFTimeOffset) and type(self) is not type(other):
169169
raise TypeError("Cannot subtract cftime offsets of differing types")
170170
return -self + other
171171

@@ -462,7 +462,7 @@ def __sub__(self, other: Self) -> Self:
462462

463463
if isinstance(other, cftime.datetime):
464464
raise TypeError("Cannot subtract cftime.datetime from offset.")
465-
if type(other) == type(self) and other.month == self.month:
465+
if type(other) is type(self) and other.month == self.month:
466466
return type(self)(self.n - other.n, month=self.month)
467467
return NotImplemented
468468

@@ -548,7 +548,7 @@ def __sub__(self, other):
548548

549549
if isinstance(other, cftime.datetime):
550550
raise TypeError("Cannot subtract cftime.datetime from offset.")
551-
elif type(other) == type(self) and other.month == self.month:
551+
elif type(other) is type(self) and other.month == self.month:
552552
return type(self)(self.n - other.n, month=self.month)
553553
else:
554554
return NotImplemented

xarray/testing/assertions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def assert_equal(a, b, from_root=True, check_dim_order: bool = True):
149149
"""
150150
__tracebackhide__ = True
151151
assert (
152-
type(a) == type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates)
152+
type(a) is type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates)
153153
)
154154
b = maybe_transpose_dims(a, b, check_dim_order)
155155
if isinstance(a, Variable | DataArray):
@@ -206,7 +206,7 @@ def assert_identical(a, b, from_root=True):
206206
"""
207207
__tracebackhide__ = True
208208
assert (
209-
type(a) == type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates)
209+
type(a) is type(b) or isinstance(a, Coordinates) and isinstance(b, Coordinates)
210210
)
211211
if isinstance(a, Variable):
212212
assert a.identical(b), formatting.diff_array_repr(a, b, "identical")
@@ -260,7 +260,7 @@ def assert_allclose(
260260
assert_identical, assert_equal, numpy.testing.assert_allclose
261261
"""
262262
__tracebackhide__ = True
263-
assert type(a) == type(b)
263+
assert type(a) is type(b)
264264
b = maybe_transpose_dims(a, b, check_dim_order)
265265

266266
equiv = functools.partial(

xarray/tests/test_distributed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,4 @@ def f(x, lock=None):
295295
await c.gather(futures)
296296

297297
lock2 = pickle.loads(pickle.dumps(lock))
298-
assert type(lock) == type(lock2)
298+
assert type(lock) is type(lock2)

xarray/tests/test_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ def setUp(self):
11771177
@pytest.mark.slow
11781178
def test_recover_from_seaborn_jet_exception(self) -> None:
11791179
pal = _color_palette("jet", 4)
1180-
assert type(pal) == np.ndarray
1180+
assert type(pal) is np.ndarray
11811181
assert len(pal) == 4
11821182

11831183
@pytest.mark.slow

xarray/tests/test_variable.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,38 +1268,38 @@ def test_detect_indexer_type(self):
12681268
v = Variable(["x", "y"], data)
12691269

12701270
_, ind, _ = v._broadcast_indexes((0, 1))
1271-
assert type(ind) == indexing.BasicIndexer
1271+
assert type(ind) is indexing.BasicIndexer
12721272

12731273
_, ind, _ = v._broadcast_indexes((0, slice(0, 8, 2)))
1274-
assert type(ind) == indexing.BasicIndexer
1274+
assert type(ind) is indexing.BasicIndexer
12751275

12761276
_, ind, _ = v._broadcast_indexes((0, [0, 1]))
1277-
assert type(ind) == indexing.OuterIndexer
1277+
assert type(ind) is indexing.OuterIndexer
12781278

12791279
_, ind, _ = v._broadcast_indexes(([0, 1], 1))
1280-
assert type(ind) == indexing.OuterIndexer
1280+
assert type(ind) is indexing.OuterIndexer
12811281

12821282
_, ind, _ = v._broadcast_indexes(([0, 1], [1, 2]))
1283-
assert type(ind) == indexing.OuterIndexer
1283+
assert type(ind) is indexing.OuterIndexer
12841284

12851285
_, ind, _ = v._broadcast_indexes(([0, 1], slice(0, 8, 2)))
1286-
assert type(ind) == indexing.OuterIndexer
1286+
assert type(ind) is indexing.OuterIndexer
12871287

12881288
vind = Variable(("a",), [0, 1])
12891289
_, ind, _ = v._broadcast_indexes((vind, slice(0, 8, 2)))
1290-
assert type(ind) == indexing.OuterIndexer
1290+
assert type(ind) is indexing.OuterIndexer
12911291

12921292
vind = Variable(("y",), [0, 1])
12931293
_, ind, _ = v._broadcast_indexes((vind, 3))
1294-
assert type(ind) == indexing.OuterIndexer
1294+
assert type(ind) is indexing.OuterIndexer
12951295

12961296
vind = Variable(("a",), [0, 1])
12971297
_, ind, _ = v._broadcast_indexes((vind, vind))
1298-
assert type(ind) == indexing.VectorizedIndexer
1298+
assert type(ind) is indexing.VectorizedIndexer
12991299

13001300
vind = Variable(("a", "b"), [[0, 2], [1, 3]])
13011301
_, ind, _ = v._broadcast_indexes((vind, 3))
1302-
assert type(ind) == indexing.VectorizedIndexer
1302+
assert type(ind) is indexing.VectorizedIndexer
13031303

13041304
def test_indexer_type(self):
13051305
# GH:issue:1688. Wrong indexer type induces NotImplementedError
@@ -2587,7 +2587,7 @@ def test_converted_types(self):
25872587
for input_array in [[[0, 1, 2]], pd.DataFrame([[0, 1, 2]])]:
25882588
actual = as_compatible_data(input_array)
25892589
assert_array_equal(np.asarray(input_array), actual)
2590-
assert np.ndarray == type(actual)
2590+
assert np.ndarray is type(actual)
25912591
assert np.asarray(input_array).dtype == actual.dtype
25922592

25932593
def test_masked_array(self):
@@ -2622,26 +2622,26 @@ def test_datetime(self):
26222622
expected = np.datetime64("2000-01-01")
26232623
actual = as_compatible_data(expected)
26242624
assert expected == actual
2625-
assert np.ndarray == type(actual)
2625+
assert np.ndarray is type(actual)
26262626
assert np.dtype("datetime64[ns]") == actual.dtype
26272627

26282628
expected = np.array([np.datetime64("2000-01-01")])
26292629
actual = as_compatible_data(expected)
26302630
assert np.asarray(expected) == actual
2631-
assert np.ndarray == type(actual)
2631+
assert np.ndarray is type(actual)
26322632
assert np.dtype("datetime64[ns]") == actual.dtype
26332633

26342634
expected = np.array([np.datetime64("2000-01-01", "ns")])
26352635
actual = as_compatible_data(expected)
26362636
assert np.asarray(expected) == actual
2637-
assert np.ndarray == type(actual)
2637+
assert np.ndarray is type(actual)
26382638
assert np.dtype("datetime64[ns]") == actual.dtype
26392639
assert expected is source_ndarray(np.asarray(actual))
26402640

26412641
expected = np.datetime64("2000-01-01", "ns")
26422642
actual = as_compatible_data(datetime(2000, 1, 1))
26432643
assert np.asarray(expected) == actual
2644-
assert np.ndarray == type(actual)
2644+
assert np.ndarray is type(actual)
26452645
assert np.dtype("datetime64[ns]") == actual.dtype
26462646

26472647
def test_tz_datetime(self) -> None:

0 commit comments

Comments
 (0)