Skip to content

Commit f63ed66

Browse files
committed
Fix mypy
1 parent 1d7da8d commit f63ed66

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

xarray/tests/arrays.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __array__(
173173
) -> np.ndarray:
174174
raise UnexpectedDataAccess("Tried accessing data")
175175

176-
def __getitem__(self, key) -> "ConcatenatableArray":
176+
def __getitem__(self, key) -> Self:
177177
"""Some cases of concat require supporting expanding dims by dimensions of size 1"""
178178
# see https://data-apis.org/array-api/2022.12/API_specification/indexing.html#multi-axis-indexing
179179
arr = self._array
@@ -186,7 +186,7 @@ def __getitem__(self, key) -> "ConcatenatableArray":
186186
raise UnexpectedDataAccess("Tried accessing data.")
187187
return ConcatenatableArray(arr)
188188

189-
def __eq__(self, other: "ConcatenatableArray") -> "ConcatenatableArray":
189+
def __eq__(self, other: Self) -> Self: # type: ignore[override]
190190
return ConcatenatableArray(self._array == other._array)
191191

192192
def __array_function__(self, func, types, args, kwargs) -> Any:
@@ -204,15 +204,15 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs) -> Any:
204204
"""We have to define this in order to convince xarray that this class is a duckarray, even though we will never support ufuncs."""
205205
return NotImplemented
206206

207-
def astype(self, dtype: np.dtype, /, *, copy: bool = True) -> "ConcatenatableArray":
207+
def astype(self, dtype: np.dtype, /, *, copy: bool = True) -> Self:
208208
"""Needed because xarray will call this even when it's a no-op"""
209209
if dtype != self.dtype:
210210
raise NotImplementedError()
211211
else:
212212
return self
213213

214-
def __and__(self, other: Self) -> "ConcatenatableArray":
214+
def __and__(self, other: Self) -> Self:
215215
return type(self)(self._array & other._array)
216216

217-
def __or__(self, other: Self) -> "ConcatenatableArray":
217+
def __or__(self, other: Self) -> Self:
218218
return type(self)(self._array | other._array)

xarray/tests/test_concat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def test_concat_multiple_datasets_missing_vars(include_day: bool) -> None:
279279
datasets = create_concat_datasets(
280280
len(vars_to_drop), seed=123, include_day=include_day
281281
)
282-
expected = concat(datasets, dim="day", **kwargs)
282+
expected = concat(datasets, dim="day", **kwargs) # type: ignore[call-overload]
283283

284284
for i, name in enumerate(vars_to_drop):
285285
if include_day:
@@ -292,8 +292,7 @@ def test_concat_multiple_datasets_missing_vars(include_day: bool) -> None:
292292
ds.drop_vars(varname)
293293
for ds, varname in zip(datasets, vars_to_drop, strict=True)
294294
]
295-
296-
actual = concat(datasets, dim="day", **kwargs)
295+
actual = concat(datasets, dim="day", **kwargs) # type: ignore[call-overload]
297296

298297
assert list(actual.data_vars.keys()) == [
299298
"pressure",

0 commit comments

Comments
 (0)