Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#9316)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent 93af904 commit 20cde77
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ 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
rev: v0.3.9
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
Expand Down
8 changes: 4 additions & 4 deletions xarray/coding/cftime_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xarray/testing/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 20cde77

Please sign in to comment.