|
74 | 74 | npt: Any = None
|
75 | 75 |
|
76 | 76 |
|
77 |
| -# Functions that take Dict/Mapping/List/Sequence/Callable can be tricky to type: |
78 |
| -# - keys of Dict and Mapping do not accept sub-classes |
79 |
| -# - items of List and Sequence do not accept sub-classes |
80 |
| -# - input argument to Callable cannot be sub-classes |
81 |
| -# If you want to allow any type and it's sub-classes in the above cases, you can |
82 |
| -# use TypeVar("AllowsSubclasses", bound=class) |
83 |
| -HashableT = TypeVar("HashableT", bound=Hashable) |
84 |
| - |
85 | 77 | # array-like
|
86 | 78 |
|
87 | 79 | ArrayLike = Union["ExtensionArray", np.ndarray]
|
|
113 | 105 | NDFrameT = TypeVar("NDFrameT", bound="NDFrame")
|
114 | 106 |
|
115 | 107 | Axis = Union[str, int]
|
116 |
| -IndexLabel = Union[Hashable, Sequence[HashableT]] |
| 108 | +IndexLabel = Union[Hashable, Sequence[Hashable]] |
117 | 109 | Level = Union[Hashable, int]
|
118 | 110 | Shape = Tuple[int, ...]
|
119 | 111 | Suffixes = Tuple[Optional[str], Optional[str]]
|
|
135 | 127 | Dtype = Union["ExtensionDtype", NpDtype]
|
136 | 128 | AstypeArg = Union["ExtensionDtype", "npt.DTypeLike"]
|
137 | 129 | # DtypeArg specifies all allowable dtypes in a functions its dtype argument
|
138 |
| -DtypeArg = Union[Dtype, Dict[HashableT, Dtype]] |
| 130 | +DtypeArg = Union[Dtype, Dict[Hashable, Dtype]] |
139 | 131 | DtypeObj = Union[np.dtype, "ExtensionDtype"]
|
140 | 132 |
|
141 | 133 | # converters
|
142 |
| -ConvertersArg = Dict[HashableT, Callable[[Dtype], Dtype]] |
| 134 | +ConvertersArg = Dict[Hashable, Callable[[Dtype], Dtype]] |
143 | 135 |
|
144 | 136 | # parse_dates
|
145 | 137 | ParseDatesArg = Union[
|
146 |
| - bool, List[HashableT], List[List[HashableT]], Dict[HashableT, List[Hashable]] |
| 138 | + bool, List[Hashable], List[List[Hashable]], Dict[Hashable, List[Hashable]] |
147 | 139 | ]
|
148 | 140 |
|
149 | 141 | # For functions like rename that convert one label to another
|
150 |
| -Renamer = Union[Mapping[HashableT, Any], Callable[[HashableT], Hashable]] |
| 142 | +Renamer = Union[Mapping[Hashable, Any], Callable[[Hashable], Hashable]] |
151 | 143 |
|
152 | 144 | # to maintain type information across generic functions and parametrization
|
153 | 145 | T = TypeVar("T")
|
|
164 | 156 |
|
165 | 157 | # types of `func` kwarg for DataFrame.aggregate and Series.aggregate
|
166 | 158 | AggFuncTypeBase = Union[Callable, str]
|
167 |
| -AggFuncTypeDict = Dict[HashableT, Union[AggFuncTypeBase, List[AggFuncTypeBase]]] |
| 159 | +AggFuncTypeDict = Dict[Hashable, Union[AggFuncTypeBase, List[AggFuncTypeBase]]] |
168 | 160 | AggFuncType = Union[
|
169 | 161 | AggFuncTypeBase,
|
170 | 162 | List[AggFuncTypeBase],
|
@@ -268,10 +260,10 @@ def closed(self) -> bool:
|
268 | 260 | FormattersType = Union[
|
269 | 261 | List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable]
|
270 | 262 | ]
|
271 |
| -ColspaceType = Mapping[HashableT, Union[str, int]] |
| 263 | +ColspaceType = Mapping[Hashable, Union[str, int]] |
272 | 264 | FloatFormatType = Union[str, Callable, "EngFormatter"]
|
273 | 265 | ColspaceArgType = Union[
|
274 |
| - str, int, Sequence[Union[str, int]], Mapping[HashableT, Union[str, int]] |
| 266 | + str, int, Sequence[Union[str, int]], Mapping[Hashable, Union[str, int]] |
275 | 267 | ]
|
276 | 268 |
|
277 | 269 | # Arguments for fillna()
|
|
0 commit comments