File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 7
7
Any ,
8
8
Callable ,
9
9
Literal ,
10
- Protocol ,
11
10
SupportsIndex ,
12
11
TypeVar ,
13
12
Union ,
18
17
from packaging .version import Version
19
18
20
19
if TYPE_CHECKING :
20
+ from numpy ._typing import _SupportsDType
21
21
from numpy .typing import ArrayLike
22
22
23
23
from xarray .backends .common import BackendEntrypoint
50
50
_ShapeLike = Union [SupportsIndex , Sequence [SupportsIndex ]]
51
51
_DTypeLikeNested = Any # TODO: wait for support for recursive types
52
52
53
- # once NumPy 1.21 is minimum version, use NumPys definition directly
54
- # 1.20 uses a non-generic Protocol (like we define here for simplicity)
55
- class _SupportsDType (Protocol ):
56
- @property
57
- def dtype (self ) -> np .dtype :
58
- ...
59
-
60
53
# Xarray requires a Mapping[Hashable, dtype] in many places which
61
54
# conflics with numpys own DTypeLike (with dtypes for fields).
62
55
# https://numpy.org/devdocs/reference/typing.html#numpy.typing.DTypeLike
63
56
# This is a copy of this DTypeLike that allows only non-Mapping dtypes.
64
57
DTypeLikeSave = Union [
65
- np .dtype ,
58
+ np .dtype [ Any ] ,
66
59
# default data type (float64)
67
60
None ,
68
61
# array-scalar types and generic types
@@ -78,7 +71,7 @@ def dtype(self) -> np.dtype:
78
71
# because numpy does the same?
79
72
list [Any ],
80
73
# anything with a dtype attribute
81
- _SupportsDType ,
74
+ _SupportsDType [ np . dtype [ Any ]] ,
82
75
]
83
76
try :
84
77
from cftime import datetime as CFTimeDatetime
You can’t perform that action at this time.
0 commit comments