diff --git a/xarray/namedarray/core.py b/xarray/namedarray/core.py index 7be458c2af1..8ca631e9000 100644 --- a/xarray/namedarray/core.py +++ b/xarray/namedarray/core.py @@ -538,7 +538,8 @@ def _nonzero(self: T_NamedArrayInteger) -> tuple[T_NamedArrayInteger, ...]: nonzeros = np.nonzero(cast(NDArray[np.integer[Any]], self.data)) _attrs = self.attrs return tuple( - _new(self, (dim,), nz, _attrs) for nz, dim in zip(nonzeros, self.dims) + (T_NamedArrayInteger, _new(self, (dim,), nz, _attrs)) + for nz, dim in zip(nonzeros, self.dims) ) def _as_sparse( diff --git a/xarray/tests/test_namedarray.py b/xarray/tests/test_namedarray.py index 606d1caae67..6b8a6483ddd 100644 --- a/xarray/tests/test_namedarray.py +++ b/xarray/tests/test_namedarray.py @@ -6,7 +6,7 @@ import pytest import xarray as xr -from xarray.namedarray._typing import _arrayfunction_or_api +from xarray.namedarray._typing import _arrayfunction_or_api, _ShapeType_co from xarray.namedarray.core import NamedArray, from_array if TYPE_CHECKING: @@ -20,7 +20,6 @@ _DType_co, _ScalarType, _Shape, - _ShapeType_co, duckarray, )