diff --git a/pyproject.toml b/pyproject.toml index 7426ff05518..b8f0f0ad829 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -198,12 +198,9 @@ module = [ "xarray.tests.test_duck_array_ops", "xarray.tests.test_indexing", "xarray.tests.test_merge", - "xarray.tests.test_missing", - "xarray.tests.test_parallelcompat", "xarray.tests.test_sparse", "xarray.tests.test_ufuncs", "xarray.tests.test_units", - "xarray.tests.test_utils", "xarray.tests.test_variable", "xarray.tests.test_weighted", ] diff --git a/xarray/tests/test_missing.py b/xarray/tests/test_missing.py index 271813d477b..ba6616a6784 100644 --- a/xarray/tests/test_missing.py +++ b/xarray/tests/test_missing.py @@ -1,6 +1,7 @@ from __future__ import annotations import itertools +from typing import Any from unittest import mock import numpy as np @@ -204,7 +205,7 @@ def test_interpolate_unsorted_index_raises(): vals = np.array([1, 2, 3], dtype=np.float64) expected = xr.DataArray(vals, dims="x", coords={"x": [2, 1, 3]}) with pytest.raises(ValueError, match=r"Index 'x' must be monotonically increasing"): - expected.interpolate_na(dim="x", method="index") + expected.interpolate_na(dim="x", method="index") # type: ignore[arg-type] def test_interpolate_no_dim_raises(): @@ -216,14 +217,14 @@ def test_interpolate_no_dim_raises(): def test_interpolate_invalid_interpolator_raises(): da = xr.DataArray(np.array([1, 2, np.nan, 5], dtype=np.float64), dims="x") with pytest.raises(ValueError, match=r"not a valid"): - da.interpolate_na(dim="x", method="foo") + da.interpolate_na(dim="x", method="foo") # type: ignore[arg-type] def test_interpolate_duplicate_values_raises(): data = np.random.randn(2, 3) da = xr.DataArray(data, coords=[("x", ["a", "a"]), ("y", [0, 1, 2])]) with pytest.raises(ValueError, match=r"Index 'x' has duplicate values"): - da.interpolate_na(dim="x", method="foo") + da.interpolate_na(dim="x", method="foo") # type: ignore[arg-type] def test_interpolate_multiindex_raises(): @@ -331,15 +332,15 @@ def test_interpolate_limits(): @requires_scipy def test_interpolate_methods(): for method in ["linear", "nearest", "zero", "slinear", "quadratic", "cubic"]: - kwargs = {} + kwargs: dict[str, Any] = {} da = xr.DataArray( np.array([0, 1, 2, np.nan, np.nan, np.nan, 6, 7, 8], dtype=np.float64), dims="x", ) - actual = da.interpolate_na("x", method=method, **kwargs) + actual = da.interpolate_na("x", method=method, **kwargs) # type: ignore[arg-type] assert actual.isnull().sum() == 0 - actual = da.interpolate_na("x", method=method, limit=2, **kwargs) + actual = da.interpolate_na("x", method=method, limit=2, **kwargs) # type: ignore[arg-type] assert actual.isnull().sum() == 1 diff --git a/xarray/tests/test_parallelcompat.py b/xarray/tests/test_parallelcompat.py index 67e3d00cfbe..558df62138b 100644 --- a/xarray/tests/test_parallelcompat.py +++ b/xarray/tests/test_parallelcompat.py @@ -48,7 +48,7 @@ def __new__( def __array_finalize__(self, obj): if obj is None: return - self.chunks = getattr(obj, "chunks", None) + self.chunks = getattr(obj, "chunks", None) # type: ignore[assignment] def rechunk(self, chunks, **kwargs): copied = self.copy() diff --git a/xarray/tests/test_utils.py b/xarray/tests/test_utils.py index 0e6bbf29a45..f3333d188cc 100644 --- a/xarray/tests/test_utils.py +++ b/xarray/tests/test_utils.py @@ -23,7 +23,7 @@ def new_method(): pass old_method = utils.alias(new_method, "old_method") - assert "deprecated" in old_method.__doc__ + assert "deprecated" in old_method.__doc__ # type: ignore[operator] with pytest.warns(Warning, match="deprecated"): old_method() @@ -102,10 +102,10 @@ def test_compat_dict_union(self): utils.compat_dict_union(self.x, self.z) def test_dict_equiv(self): - x = {} + x: dict = {} x["a"] = 3 x["b"] = np.array([1, 2, 3]) - y = {} + y: dict = {} y["b"] = np.array([1.0, 2.0, 3.0]) y["a"] = 3 assert utils.dict_equiv(x, y) # two nparrays are equal @@ -129,11 +129,11 @@ def test_dict_equiv(self): def test_frozen(self): x = utils.Frozen(self.x) with pytest.raises(TypeError): - x["foo"] = "bar" + x["foo"] = "bar" # type: ignore[index] with pytest.raises(TypeError): - del x["a"] + del x["a"] # type: ignore[attr-defined] with pytest.raises(AttributeError): - x.update(self.y) + x.update(self.y) # type: ignore[attr-defined] assert x.mapping == self.x assert repr(x) in ( "Frozen({'a': 'A', 'b': 'B'})", @@ -231,11 +231,11 @@ def test_hidden_key_dict(): def test_either_dict_or_kwargs(): - result = either_dict_or_kwargs(dict(a=1), None, "foo") + result = either_dict_or_kwargs(dict(a=1), {}, "foo") expected = dict(a=1) assert result == expected - result = either_dict_or_kwargs(None, dict(a=1), "foo") + result = either_dict_or_kwargs({}, dict(a=1), "foo") expected = dict(a=1) assert result == expected