forked from pandas-dev/pandas-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_typing.pyi
205 lines (181 loc) · 5.67 KB
/
_typing.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import datetime
from io import (
BufferedIOBase,
RawIOBase,
TextIOBase,
TextIOWrapper,
)
from mmap import mmap
from os import PathLike
from pathlib import Path
import sys
from typing import (
IO,
Any,
AnyStr,
Callable,
Collection,
Dict,
Hashable,
List,
Literal,
Mapping,
NewType,
Optional,
Protocol,
Sequence,
Tuple,
Type,
TypeVar,
Union,
)
import numpy as np
from numpy import typing as npt
from pandas.core.arrays import ExtensionArray
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame
from pandas.core.indexes.base import Index
from pandas.core.series import Series
from pandas._libs.tslibs import (
Period,
Timedelta,
Timestamp,
)
from pandas.core.dtypes.dtypes import ExtensionDtype
ArrayLike = Union[ExtensionArray, np.ndarray]
AnyArrayLike = Union[Index, Series, np.ndarray]
PythonScalar = Union[str, int, float, bool, complex]
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", Period, Timestamp, Timedelta)
PandasScalar = Union[bytes, datetime.date, datetime.datetime, datetime.timedelta]
# Scalar = Union[PythonScalar, PandasScalar]
IntStrT = TypeVar("IntStrT", int, str)
# dtypes
NpDtype = Union[
str, np.dtype[np.generic], Type[Union[str, float, int, complex, bool, object]]
]
Dtype = Union[ExtensionDtype, NpDtype]
AstypeArg = Union[ExtensionDtype, npt.DTypeLike]
# DtypeArg specifies all allowable dtypes in a functions its dtype argument
DtypeArg = Union[Dtype, Dict[Any, Dtype]]
DtypeObj = Union[np.dtype[np.generic], ExtensionDtype]
# filenames and file-like-objects
AnyStr_cov = TypeVar("AnyStr_cov", str, bytes, covariant=True)
AnyStr_con = TypeVar("AnyStr_con", str, bytes, contravariant=True)
class BaseBuffer(Protocol): ...
class ReadBuffer(BaseBuffer, Protocol[AnyStr_cov]): ...
class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ...
FilePath = Union[str, PathLike[str]]
Buffer = Union[IO[AnyStr], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]
FileOrBuffer = Union[str, Buffer[AnyStr]]
FilePathOrBuffer = Union[PathLike[str], FileOrBuffer[AnyStr]]
FilePathOrBytesBuffer = Union[PathLike[str], WriteBuffer[bytes]]
FrameOrSeries = TypeVar("FrameOrSeries", bound=NDFrame)
FrameOrSeriesUnion = Union[DataFrame, Series]
Axis = Union[str, int]
IndexLabel = Union[Hashable, Sequence[Hashable]]
Label = Optional[Hashable]
Level = Union[Hashable, int]
Ordered = Optional[bool]
JSONSerializable = Union[PythonScalar, List, Dict]
Axes = Union[AnyArrayLike, List, Dict, range]
Renamer = Union[Mapping[Any, Label], Callable[[Any], Label]]
T = TypeVar("T")
FuncType = Callable[..., Any]
F = TypeVar("F", bound=FuncType)
HashableT = TypeVar("HashableT", bound=Hashable)
AggFuncTypeBase = Union[Callable, str]
AggFuncTypeDict = Dict[Hashable, Union[AggFuncTypeBase, List[AggFuncTypeBase]]]
AggFuncType = Union[
AggFuncTypeBase,
List[AggFuncTypeBase],
AggFuncTypeDict,
]
num = Union[int, float, complex]
SeriesAxisType = Literal["index", 0] # Restricted subset of _AxisType for series
AxisType = Literal["columns", "index", 0, 1]
DtypeNp = TypeVar("DtypeNp", bound=np.dtype[np.generic])
KeysArgType = Any
ListLike = TypeVar("ListLike", Sequence, np.ndarray, "Series")
StrLike = Union[str, np.str_]
Scalar = Union[
str,
bytes,
datetime.date,
datetime.datetime,
datetime.timedelta,
bool,
int,
float,
complex,
Timestamp,
Timedelta,
]
ScalarT = TypeVar("ScalarT", bound=Scalar)
# Refine the definitions below in 3.9 to use the specialized type.
np_ndarray_int8 = npt.NDArray[np.int8]
np_ndarray_int16 = npt.NDArray[np.int16]
np_ndarray_int32 = npt.NDArray[np.int32]
np_ndarray_int64 = npt.NDArray[np.int64]
np_ndarray_uint8 = npt.NDArray[np.uint8]
np_ndarray_uint16 = npt.NDArray[np.uint16]
np_ndarray_uint32 = npt.NDArray[np.uint32]
np_ndarray_uint64 = npt.NDArray[np.uint64]
np_ndarray_int = Union[
np_ndarray_int8, np_ndarray_int16, np_ndarray_int32, np_ndarray_int64
]
np_ndarray_uint = Union[
np_ndarray_uint8, np_ndarray_uint16, np_ndarray_uint32, np_ndarray_uint64
]
np_ndarray_anyint = Union[np_ndarray_int, np_ndarray_uint]
np_ndarray_bool = npt.NDArray[np.bool_]
np_ndarray_str = npt.NDArray[np.str_]
IndexType = Union[slice, np_ndarray_int64, Index, List[int], Series[int]]
MaskType = Union[Series[bool], np_ndarray_bool, List[bool]]
# Scratch types for generics
S1 = TypeVar(
"S1",
str,
bytes,
datetime.date,
datetime.datetime,
datetime.timedelta,
bool,
int,
float,
complex,
Timestamp,
Timedelta,
np.datetime64,
)
T1 = TypeVar(
"T1", str, int, np.int64, np.uint64, np.float64, float, np.dtype[np.generic]
)
T2 = TypeVar("T2", str, int)
IndexingInt = Union[
int, np.int_, np.integer, np.unsignedinteger, np.signedinteger, np.int8
]
# Interval closed type
IntervalClosedType = Literal["left", "right", "both", "neither"]
DateTimeErrorChoices = Literal["ignore", "raise", "coerce"]
# Shared by functions such as drop and astype
IgnoreRaise = Literal["ignore", "raise"]
# for arbitrary kwargs passed during reading/writing files
StorageOptions = Optional[Dict[str, Any]]
# compression keywords and compression
CompressionDict = Dict[str, Any]
CompressionOptions = Optional[
Union[Literal["infer", "gzip", "bz2", "zip", "xz", "zstd"], CompressionDict]
]
# converters
ConvertersArg = Dict[Hashable, Callable[[Dtype], Dtype]]
# parse_dates
ParseDatesArg = Union[
bool, List[Hashable], List[List[Hashable]], Dict[Hashable, List[Hashable]]
]
# read_xml parsers
XMLParsers = Literal["lxml", "etree"]
# Any plain Python or numpy function
Function = Union[np.ufunc, Callable[..., Any]]
GroupByObject = Union[
Label, List[Label], Function, Series, np.ndarray, Mapping[Label, Any], Index
]