10
10
11
11
import math
12
12
import sys
13
+ from collections .abc import Iterable , Iterator , Mapping , Sequence
13
14
from numbers import Real
14
15
from types import SimpleNamespace
15
16
from typing import (
16
17
TYPE_CHECKING ,
17
18
Any ,
18
- Iterable ,
19
- Iterator ,
20
- List ,
21
19
Literal ,
22
- Mapping ,
23
20
NamedTuple ,
24
21
Optional ,
25
- Sequence ,
26
- Tuple ,
27
- Type ,
28
22
TypeVar ,
29
23
Union ,
30
24
get_args ,
89
83
90
84
91
85
@check_function
92
- def check_xp_attributes (xp : Any , attributes : List [str ]) -> None :
86
+ def check_xp_attributes (xp : Any , attributes : list [str ]) -> None :
93
87
missing_attrs = [attr for attr in attributes if not hasattr (xp , attr )]
94
88
if len (missing_attrs ) > 0 :
95
89
f_attrs = ", " .join (missing_attrs )
@@ -100,7 +94,7 @@ def check_xp_attributes(xp: Any, attributes: List[str]) -> None:
100
94
101
95
def partition_attributes_and_stubs (
102
96
xp : Any , attributes : Iterable [str ]
103
- ) -> Tuple [ List [Any ], List [str ]]:
97
+ ) -> tuple [ list [Any ], list [str ]]:
104
98
non_stubs = []
105
99
stubs = []
106
100
for attr in attributes :
@@ -112,7 +106,7 @@ def partition_attributes_and_stubs(
112
106
return non_stubs , stubs
113
107
114
108
115
- def warn_on_missing_dtypes (xp : Any , stubs : List [str ]) -> None :
109
+ def warn_on_missing_dtypes (xp : Any , stubs : list [str ]) -> None :
116
110
f_stubs = ", " .join (stubs )
117
111
warn (
118
112
f"Array module { xp .__name__ } does not have the following "
@@ -124,7 +118,7 @@ def warn_on_missing_dtypes(xp: Any, stubs: List[str]) -> None:
124
118
125
119
def find_castable_builtin_for_dtype (
126
120
xp : Any , api_version : NominalVersion , dtype : DataType
127
- ) -> Type [Union [bool , int , float , complex ]]:
121
+ ) -> type [Union [bool , int , float , complex ]]:
128
122
"""Returns builtin type which can have values that are castable to the given
129
123
dtype, according to :xp-ref:`type promotion rules <type_promotion.html>`.
130
124
@@ -591,7 +585,7 @@ def _arrays(
591
585
592
586
593
587
@check_function
594
- def check_dtypes (xp : Any , dtypes : List [DataType ], stubs : List [str ]) -> None :
588
+ def check_dtypes (xp : Any , dtypes : list [DataType ], stubs : list [str ]) -> None :
595
589
if len (dtypes ) == 0 :
596
590
assert len (stubs ) > 0 , "No dtypes passed but stubs is empty"
597
591
f_stubs = ", " .join (stubs )
0 commit comments