@@ -5,40 +5,57 @@ import numpy as np
5
5
import sys
6
6
from os import PathLike
7
7
from pathlib import Path
8
- from typing import Any , AnyStr , Callable , Collection , Dict , Hashable , IO , List , Mapping , NewType , Optional , Sequence , Type , TypeVar , Union
8
+ from typing import (
9
+ Any ,
10
+ AnyStr ,
11
+ Callable ,
12
+ Collection ,
13
+ Dict ,
14
+ Hashable ,
15
+ IO ,
16
+ List ,
17
+ Mapping ,
18
+ NewType ,
19
+ Optional ,
20
+ Sequence ,
21
+ Type ,
22
+ TypeVar ,
23
+ Union ,
24
+ )
9
25
10
26
from pandas .core .generic import NDFrame
11
27
from pandas ._libs .tslibs import Period , Timedelta , Timestamp
12
28
from pandas .core .arrays import ExtensionArray
13
29
from pandas .core .series import Series
14
30
from pandas .core .indexes .base import Index
31
+
15
32
if sys .version_info >= (3 , 8 ):
16
33
from typing import Literal
17
34
else :
18
35
from typing_extensions import Literal
19
36
20
- AnyArrayLike = TypeVar (' AnyArrayLike' , ExtensionArray , Index , Series , np .ndarray )
21
- ArrayLike = TypeVar (' ArrayLike' , ExtensionArray , np .ndarray )
37
+ AnyArrayLike = TypeVar (" AnyArrayLike" , ExtensionArray , Index , Series , np .ndarray )
38
+ ArrayLike = TypeVar (" ArrayLike" , ExtensionArray , np .ndarray )
22
39
PythonScalar = Union [str , int , float , bool , complex ]
23
- DatetimeLikeScalar = TypeVar (' DatetimeLikeScalar' , Period , Timestamp , Timedelta )
40
+ DatetimeLikeScalar = TypeVar (" DatetimeLikeScalar" , Period , Timestamp , Timedelta )
24
41
PandasScalar = Union [bytes , datetime .date , datetime .datetime , datetime .timedelta ]
25
- #Scalar = Union[PythonScalar, PandasScalar]
26
- #Dtype: Any
42
+ # Scalar = Union[PythonScalar, PandasScalar]
43
+ # Dtype: Any
27
44
28
45
# filenames and file-like-objects
29
46
Buffer = Union [IO [AnyStr ], RawIOBase , BufferedIOBase , TextIOBase , TextIOWrapper , mmap ]
30
47
FileOrBuffer = Union [str , Buffer [AnyStr ]]
31
48
FilePathOrBuffer = Union ["PathLike[str]" , FileOrBuffer [AnyStr ]]
32
49
33
- FrameOrSeries = TypeVar (' FrameOrSeries' , bound = NDFrame )
50
+ FrameOrSeries = TypeVar (" FrameOrSeries" , bound = NDFrame )
34
51
Axis = Union [str , int ]
35
52
Label = Optional [Hashable ]
36
53
Level = Union [Label , int ]
37
54
Ordered = Optional [bool ]
38
55
JSONSerializable = Union [PythonScalar , List , Dict ]
39
56
Axes = Collection
40
57
Renamer = Union [Mapping [Label , Any ], Callable [[Label ], Label ]]
41
- T = TypeVar ('T' )
58
+ T = TypeVar ("T" )
42
59
FuncType = Callable [..., Any ]
43
60
F = TypeVar ("F" , bound = FuncType )
44
61
@@ -56,7 +73,7 @@ AxisType = Union[str, int, Literal["columns", "index", 0, 1]]
56
73
Dtype = TypeVar ("Dtype" , bool , int , float , object )
57
74
DtypeNp = TypeVar ("DtypeNp" , bound = np .dtype )
58
75
KeysArgType = Any
59
- ListLike = TypeVar ("ListLike" , Sequence , np .ndarray , ' Series' )
76
+ ListLike = TypeVar ("ListLike" , Sequence , np .ndarray , " Series" )
60
77
StrLike = Union [str , np .str_ ]
61
78
Scalar = Union [str , bytes , datetime .date , datetime .datetime , datetime .timedelta , bool , int , float , complex , Timestamp , Timedelta ]
62
79
# Refine the next 3 in 3.9 to use the specialized type.
@@ -66,8 +83,8 @@ np_ndarray_str = NewType("np_ndarray_str", Type[np.ndarray])
66
83
IndexType = Union [slice , np_ndarray_int64 , Index [int ], List [int ], Series [int ]]
67
84
MaskType = Union [Series [bool ], np_ndarray_bool , Sequence [bool ]]
68
85
# Scratch types for generics
69
- S1 = TypeVar ("S1" , str , bytes , datetime .date , datetime .datetime , datetime .timedelta , bool , int , float , complex , Timestamp , Timedelta )
86
+ S1 = TypeVar (
87
+ "S1" , str , bytes , datetime .date , datetime .datetime , datetime .timedelta , bool , int , float , complex , Timestamp , Timedelta
88
+ )
70
89
T1 = TypeVar ("T1" , str , int )
71
90
T2 = TypeVar ("T2" , str , int )
72
-
73
-
0 commit comments