1010
1111import math
1212import sys
13+ from collections .abc import Iterable , Iterator , Mapping , Sequence
1314from numbers import Real
1415from types import SimpleNamespace
1516from typing import (
1617 TYPE_CHECKING ,
1718 Any ,
18- Iterable ,
19- Iterator ,
20- List ,
2119 Literal ,
22- Mapping ,
2320 NamedTuple ,
2421 Optional ,
25- Sequence ,
26- Tuple ,
27- Type ,
2822 TypeVar ,
2923 Union ,
3024 get_args ,
8983
9084
9185@check_function
92- def check_xp_attributes (xp : Any , attributes : List [str ]) -> None :
86+ def check_xp_attributes (xp : Any , attributes : list [str ]) -> None :
9387 missing_attrs = [attr for attr in attributes if not hasattr (xp , attr )]
9488 if len (missing_attrs ) > 0 :
9589 f_attrs = ", " .join (missing_attrs )
@@ -100,7 +94,7 @@ def check_xp_attributes(xp: Any, attributes: List[str]) -> None:
10094
10195def partition_attributes_and_stubs (
10296 xp : Any , attributes : Iterable [str ]
103- ) -> Tuple [ List [Any ], List [str ]]:
97+ ) -> tuple [ list [Any ], list [str ]]:
10498 non_stubs = []
10599 stubs = []
106100 for attr in attributes :
@@ -112,7 +106,7 @@ def partition_attributes_and_stubs(
112106 return non_stubs , stubs
113107
114108
115- def warn_on_missing_dtypes (xp : Any , stubs : List [str ]) -> None :
109+ def warn_on_missing_dtypes (xp : Any , stubs : list [str ]) -> None :
116110 f_stubs = ", " .join (stubs )
117111 warn (
118112 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:
124118
125119def find_castable_builtin_for_dtype (
126120 xp : Any , api_version : NominalVersion , dtype : DataType
127- ) -> Type [Union [bool , int , float , complex ]]:
121+ ) -> type [Union [bool , int , float , complex ]]:
128122 """Returns builtin type which can have values that are castable to the given
129123 dtype, according to :xp-ref:`type promotion rules <type_promotion.html>`.
130124
@@ -591,7 +585,7 @@ def _arrays(
591585
592586
593587@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 :
595589 if len (dtypes ) == 0 :
596590 assert len (stubs ) > 0 , "No dtypes passed but stubs is empty"
597591 f_stubs = ", " .join (stubs )
0 commit comments