Skip to content

Commit

Permalink
Update test_namedarray.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Oct 14, 2023
1 parent 8fe9828 commit edc1dbb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions xarray/tests/test_namedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import pytest

import xarray as xr
from xarray.namedarray._typing import _arrayfunction_or_api, _ShapeType_co
from xarray.namedarray._typing import (
_arrayfunction_or_api,
_DType_co,
_ScalarType,
_ShapeType_co,
DuckArray,
)
from xarray.namedarray.core import NamedArray, from_array

if TYPE_CHECKING:
Expand All @@ -15,10 +21,7 @@
from numpy.typing import NDArray

from xarray.namedarray._typing import (
DuckArray,
_DimsLike,
_DType_co,
_ScalarType,
_Shape,
duckarray,
)
Expand Down Expand Up @@ -238,9 +241,7 @@ def test_duck_array_typevar(a: DuckArray[_ScalarType]) -> DuckArray[_ScalarType]

# Runtime check if valid:
if isinstance(b, _arrayfunction_or_api):
# TODO: cast is a mypy workaround for https://github.com/python/mypy/issues/10817
# pyright doesn't need it.
return cast(DuckArray[_ScalarType], b)
return b
else:
raise TypeError(f"a ({type(a)}) is not a valid _arrayfunction or _arrayapi")

Expand Down

0 comments on commit edc1dbb

Please sign in to comment.