From 6cc75cc8b5bf9bdfc2bc79be9ee973e93a57840b Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:13:11 +0200 Subject: [PATCH] Update _typing.py --- xarray/namedarray/_typing.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/xarray/namedarray/_typing.py b/xarray/namedarray/_typing.py index d7e8d4a5b51..b052e5ee76e 100644 --- a/xarray/namedarray/_typing.py +++ b/xarray/namedarray/_typing.py @@ -12,7 +12,6 @@ Literal, Protocol, SupportsIndex, - TypeAlias, TypeVar, Union, overload, @@ -44,7 +43,7 @@ class Default(Enum): _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) -_generic: TypeAlias = Any +_generic = Any # _generic = np.generic @@ -69,8 +68,8 @@ def __eq__(self, other: _DType2[_generic], /) -> bool: _dtype = np.dtype -_DType = TypeVar("_DType", bound=np.dtype[Any]) -_DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype[Any]) +_DType = TypeVar("_DType", bound=_dtype[Any]) +_DType_co = TypeVar("_DType_co", covariant=True, bound=_dtype[Any]) # A subset of `npt.DTypeLike` that can be parametrized w.r.t. `np.generic` # _ScalarType = TypeVar("_ScalarType", bound=_generic) @@ -87,9 +86,9 @@ def dtype(self) -> _DType_co: ... _DTypeLike = Union[ - np.dtype[_ScalarType], + _dtype[_ScalarType], type[_ScalarType], - _SupportsDType[np.dtype[_ScalarType]], + _SupportsDType[_dtype[_ScalarType]], ] # For unknown shapes Dask uses np.nan, array_api uses None: @@ -249,7 +248,7 @@ def __array_namespace__(self) -> ModuleType: ... ] # Corresponds to np.typing.NDArray: -DuckArray = _arrayfunction[Any, np.dtype[_ScalarType_co]] +DuckArray = _arrayfunction[Any, _dtype[_ScalarType_co]] @runtime_checkable