|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
| 3 | +from collections.abc import ( |
| 4 | + Hashable, |
| 5 | + Iterator, |
| 6 | + Mapping, |
| 7 | + Sequence, |
| 8 | +) |
3 | 9 | from datetime import (
|
4 | 10 | datetime,
|
5 | 11 | timedelta,
|
|
11 | 17 | TYPE_CHECKING,
|
12 | 18 | Any,
|
13 | 19 | Callable,
|
14 |
| - Dict, |
15 |
| - Hashable, |
16 |
| - Iterator, |
17 |
| - List, |
18 | 20 | Literal,
|
19 |
| - Mapping, |
20 | 21 | Optional,
|
21 | 22 | Protocol,
|
22 |
| - Sequence, |
23 |
| - Tuple, |
24 | 23 | Type as type_t,
|
25 | 24 | TypeVar,
|
26 | 25 | Union,
|
|
111 | 110 | # Cannot use `Sequence` because a string is a sequence, and we don't want to
|
112 | 111 | # accept that. Could refine if https://github.com/python/typing/issues/256 is
|
113 | 112 | # resolved to differentiate between Sequence[str] and str
|
114 |
| -ListLike = Union[AnyArrayLike, List, range] |
| 113 | +ListLike = Union[AnyArrayLike, list, range] |
115 | 114 |
|
116 | 115 | # scalars
|
117 | 116 |
|
|
146 | 145 | Axis = Union[AxisInt, Literal["index", "columns", "rows"]]
|
147 | 146 | IndexLabel = Union[Hashable, Sequence[Hashable]]
|
148 | 147 | Level = Hashable
|
149 |
| -Shape = Tuple[int, ...] |
150 |
| -Suffixes = Tuple[Optional[str], Optional[str]] |
| 148 | +Shape = tuple[int, ...] |
| 149 | +Suffixes = tuple[Optional[str], Optional[str]] |
151 | 150 | Ordered = Optional[bool]
|
152 |
| -JSONSerializable = Optional[Union[PythonScalar, List, Dict]] |
| 151 | +JSONSerializable = Optional[Union[PythonScalar, list, dict]] |
153 | 152 | Frequency = Union[str, "BaseOffset"]
|
154 | 153 | Axes = ListLike
|
155 | 154 |
|
|
166 | 165 | Dtype = Union["ExtensionDtype", NpDtype]
|
167 | 166 | AstypeArg = Union["ExtensionDtype", "npt.DTypeLike"]
|
168 | 167 | # DtypeArg specifies all allowable dtypes in a functions its dtype argument
|
169 |
| -DtypeArg = Union[Dtype, Dict[Hashable, Dtype]] |
| 168 | +DtypeArg = Union[Dtype, dict[Hashable, Dtype]] |
170 | 169 | DtypeObj = Union[np.dtype, "ExtensionDtype"]
|
171 | 170 |
|
172 | 171 | # converters
|
173 |
| -ConvertersArg = Dict[Hashable, Callable[[Dtype], Dtype]] |
| 172 | +ConvertersArg = dict[Hashable, Callable[[Dtype], Dtype]] |
174 | 173 |
|
175 | 174 | # parse_dates
|
176 | 175 | ParseDatesArg = Union[
|
177 |
| - bool, List[Hashable], List[List[Hashable]], Dict[Hashable, List[Hashable]] |
| 176 | + bool, list[Hashable], list[list[Hashable]], dict[Hashable, list[Hashable]] |
178 | 177 | ]
|
179 | 178 |
|
180 | 179 | # For functions like rename that convert one label to another
|
|
195 | 194 |
|
196 | 195 | # types of `func` kwarg for DataFrame.aggregate and Series.aggregate
|
197 | 196 | AggFuncTypeBase = Union[Callable, str]
|
198 |
| -AggFuncTypeDict = Dict[Hashable, Union[AggFuncTypeBase, List[AggFuncTypeBase]]] |
| 197 | +AggFuncTypeDict = dict[Hashable, Union[AggFuncTypeBase, list[AggFuncTypeBase]]] |
199 | 198 | AggFuncType = Union[
|
200 | 199 | AggFuncTypeBase,
|
201 |
| - List[AggFuncTypeBase], |
| 200 | + list[AggFuncTypeBase], |
202 | 201 | AggFuncTypeDict,
|
203 | 202 | ]
|
204 | 203 | AggObjType = Union[
|
@@ -286,18 +285,18 @@ def closed(self) -> bool:
|
286 | 285 | FilePath = Union[str, "PathLike[str]"]
|
287 | 286 |
|
288 | 287 | # for arbitrary kwargs passed during reading/writing files
|
289 |
| -StorageOptions = Optional[Dict[str, Any]] |
| 288 | +StorageOptions = Optional[dict[str, Any]] |
290 | 289 |
|
291 | 290 |
|
292 | 291 | # compression keywords and compression
|
293 |
| -CompressionDict = Dict[str, Any] |
| 292 | +CompressionDict = dict[str, Any] |
294 | 293 | CompressionOptions = Optional[
|
295 | 294 | Union[Literal["infer", "gzip", "bz2", "zip", "xz", "zstd", "tar"], CompressionDict]
|
296 | 295 | ]
|
297 | 296 |
|
298 | 297 | # types in DataFrameFormatter
|
299 | 298 | FormattersType = Union[
|
300 |
| - List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable] |
| 299 | + list[Callable], tuple[Callable, ...], Mapping[Union[str, int], Callable] |
301 | 300 | ]
|
302 | 301 | ColspaceType = Mapping[Hashable, Union[str, int]]
|
303 | 302 | FloatFormatType = Union[str, Callable, "EngFormatter"]
|
@@ -347,9 +346,9 @@ def closed(self) -> bool:
|
347 | 346 | # https://bugs.python.org/issue41810
|
348 | 347 | # Using List[int] here rather than Sequence[int] to disallow tuples.
|
349 | 348 | ScalarIndexer = Union[int, np.integer]
|
350 |
| -SequenceIndexer = Union[slice, List[int], np.ndarray] |
| 349 | +SequenceIndexer = Union[slice, list[int], np.ndarray] |
351 | 350 | PositionalIndexer = Union[ScalarIndexer, SequenceIndexer]
|
352 |
| -PositionalIndexerTuple = Tuple[PositionalIndexer, PositionalIndexer] |
| 351 | +PositionalIndexerTuple = tuple[PositionalIndexer, PositionalIndexer] |
353 | 352 | PositionalIndexer2D = Union[PositionalIndexer, PositionalIndexerTuple]
|
354 | 353 | if TYPE_CHECKING:
|
355 | 354 | TakeIndexer = Union[Sequence[int], Sequence[np.integer], npt.NDArray[np.integer]]
|
|
0 commit comments