|
1 | 1 | from collections.abc import Callable |
| 2 | +import sys |
2 | 3 | from typing import ( |
3 | 4 | Any, |
4 | 5 | Literal, |
5 | 6 | overload, |
6 | 7 | ) |
7 | 8 |
|
8 | | -from pandas import ( |
9 | | - Index, |
10 | | - Series, |
11 | | -) |
| 9 | +import numpy as np |
12 | 10 | from pandas.core.arrays.boolean import BooleanArray |
| 11 | +from pandas.core.indexes.base import Index |
| 12 | +from pandas.core.series import Series |
13 | 13 | from typing_extensions import Self |
14 | 14 |
|
| 15 | +from pandas._typing import Scalar |
| 16 | + |
15 | 17 | class NAType: |
16 | 18 | def __new__(cls, *args: Any, **kwargs: Any) -> Self: ... |
17 | 19 | def __format__(self, format_spec: str) -> str: ... |
18 | 20 | def __hash__(self) -> int: ... |
19 | 21 | def __reduce__(self) -> str: ... |
20 | 22 | @overload |
21 | | - def __add__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
22 | | - self, other: Series, / |
23 | | - ) -> Series: ... |
| 23 | + def __add__(self, other: Series, /) -> Series: ... |
24 | 24 | @overload |
25 | | - def __add__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 25 | + def __add__(self, other: Index, /) -> Index: ... |
26 | 26 | @overload |
27 | | - def __add__(self, other: object, /) -> NAType: ... |
| 27 | + def __add__(self, other: Scalar, /) -> NAType: ... |
28 | 28 | @overload |
29 | | - def __radd__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
30 | | - self, other: Series, / |
31 | | - ) -> Series: ... |
| 29 | + def __radd__(self, other: Series, /) -> Series: ... |
32 | 30 | @overload |
33 | | - def __radd__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 31 | + def __radd__(self, other: Index, /) -> Index: ... |
| 32 | + if sys.version_info >= (3, 11): |
| 33 | + @overload |
| 34 | + def __radd__(self, other: Scalar, /) -> NAType: ... |
| 35 | + else: |
| 36 | + @overload |
| 37 | + def __radd__(self, other: Scalar, /) -> NAType: ... # type: ignore[misc] |
| 38 | + |
34 | 39 | @overload |
35 | | - def __radd__(self, other: object, /) -> NAType: ... |
| 40 | + def __sub__(self, other: Series, /) -> Series: ... |
36 | 41 | @overload |
37 | | - def __sub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
38 | | - self, other: Series, / |
39 | | - ) -> Series: ... |
| 42 | + def __sub__(self, other: Index, /) -> Index: ... |
40 | 43 | @overload |
41 | | - def __sub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 44 | + def __sub__(self, other: Scalar, /) -> NAType: ... |
42 | 45 | @overload |
43 | | - def __sub__(self, other: object, /) -> NAType: ... |
| 46 | + def __rsub__(self, other: Series, /) -> Series: ... |
44 | 47 | @overload |
45 | | - def __rsub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
46 | | - self, other: Series, / |
47 | | - ) -> Series: ... |
| 48 | + def __rsub__(self, other: Index, /) -> Index: ... |
48 | 49 | @overload |
49 | | - def __rsub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 50 | + def __rsub__(self, other: Scalar, /) -> NAType: ... |
50 | 51 | @overload |
51 | | - def __rsub__(self, other: object, /) -> NAType: ... |
| 52 | + def __mul__(self, other: Series, /) -> Series: ... |
52 | 53 | @overload |
53 | | - def __mul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
54 | | - self, other: Series, / |
55 | | - ) -> Series: ... |
| 54 | + def __mul__(self, other: Index, /) -> Index: ... |
56 | 55 | @overload |
57 | | - def __mul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 56 | + def __mul__(self, other: Scalar, /) -> NAType: ... |
58 | 57 | @overload |
59 | | - def __mul__(self, other: object, /) -> NAType: ... |
| 58 | + def __rmul__(self, other: Series, /) -> Series: ... |
60 | 59 | @overload |
61 | | - def __rmul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
62 | | - self, other: Series, / |
63 | | - ) -> Series: ... |
| 60 | + def __rmul__(self, other: Index, /) -> Index: ... |
64 | 61 | @overload |
65 | | - def __rmul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 62 | + def __rmul__(self, other: Scalar, /) -> NAType: ... |
| 63 | + def __matmul__(self, other: Scalar, /) -> NAType: ... |
| 64 | + def __rmatmul__(self, other: Scalar, /) -> NAType: ... |
66 | 65 | @overload |
67 | | - def __rmul__(self, other: object, /) -> NAType: ... |
68 | | - def __matmul__(self, other: object, /) -> NAType: ... |
69 | | - def __rmatmul__(self, other: object, /) -> NAType: ... |
| 66 | + def __truediv__(self, other: Series, /) -> Series: ... |
70 | 67 | @overload |
71 | | - def __truediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
72 | | - self, other: Series, / |
73 | | - ) -> Series: ... |
| 68 | + def __truediv__(self, other: Index, /) -> Index: ... |
74 | 69 | @overload |
75 | | - def __truediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 70 | + def __truediv__(self, other: Scalar, /) -> NAType: ... |
76 | 71 | @overload |
77 | | - def __truediv__(self, other: object, /) -> NAType: ... |
| 72 | + def __rtruediv__(self, other: Series, /) -> Series: ... |
78 | 73 | @overload |
79 | | - def __rtruediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
80 | | - self, other: Series, / |
81 | | - ) -> Series: ... |
| 74 | + def __rtruediv__(self, other: Index, /) -> Index: ... |
82 | 75 | @overload |
83 | | - def __rtruediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 76 | + def __rtruediv__(self, other: Scalar, /) -> NAType: ... |
84 | 77 | @overload |
85 | | - def __rtruediv__(self, other: object, /) -> NAType: ... |
| 78 | + def __floordiv__(self, other: Series, /) -> Series: ... |
86 | 79 | @overload |
87 | | - def __floordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
88 | | - self, other: Series, / |
89 | | - ) -> Series: ... |
| 80 | + def __floordiv__(self, other: Index, /) -> Index: ... |
90 | 81 | @overload |
91 | | - def __floordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 82 | + def __floordiv__(self, other: Scalar, /) -> NAType: ... |
92 | 83 | @overload |
93 | | - def __floordiv__(self, other: object, /) -> NAType: ... |
| 84 | + def __rfloordiv__(self, other: Series, /) -> Series: ... |
94 | 85 | @overload |
95 | | - def __rfloordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
96 | | - self, other: Series, / |
97 | | - ) -> Series: ... |
98 | | - @overload |
99 | | - def __rfloordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 86 | + def __rfloordiv__(self, other: Index, /) -> Index: ... |
100 | 87 | @overload |
101 | | - def __rfloordiv__(self, other: object, /) -> NAType: ... |
| 88 | + def __rfloordiv__(self, other: Scalar, /) -> NAType: ... |
102 | 89 | @overload |
103 | | - def __mod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
104 | | - self, other: Series, / |
105 | | - ) -> Series: ... |
| 90 | + def __mod__(self, other: Series, /) -> Series: ... |
106 | 91 | @overload |
107 | | - def __mod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 92 | + def __mod__(self, other: Index, /) -> Index: ... |
108 | 93 | @overload |
109 | | - def __mod__(self, other: object, /) -> NAType: ... |
| 94 | + def __mod__(self, other: Scalar, /) -> NAType: ... |
110 | 95 | @overload |
111 | | - def __rmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
112 | | - self, other: Series, / |
113 | | - ) -> Series: ... |
| 96 | + def __rmod__(self, other: Series, /) -> Series: ... |
114 | 97 | @overload |
115 | | - def __rmod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 98 | + def __rmod__(self, other: Index, /) -> Index: ... |
116 | 99 | @overload |
117 | | - def __rmod__(self, other: object, /) -> NAType: ... |
| 100 | + def __rmod__(self, other: Scalar, /) -> NAType: ... |
118 | 101 | @overload |
119 | | - def __divmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
120 | | - self, other: Series, / |
121 | | - ) -> tuple[Series, Series]: ... |
| 102 | + def __divmod__(self, other: Series, /) -> tuple[Series, Series]: ... |
122 | 103 | @overload |
123 | | - def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap] |
| 104 | + def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ... |
124 | 105 | @overload |
125 | | - def __divmod__(self, other: object, /) -> tuple[NAType, NAType]: ... |
| 106 | + def __divmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ... |
126 | 107 | @overload |
127 | | - def __rdivmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
128 | | - self, other: Series, / |
129 | | - ) -> tuple[Series, Series]: ... |
| 108 | + def __rdivmod__(self, other: Series, /) -> tuple[Series, Series]: ... |
130 | 109 | @overload |
131 | | - def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap] |
| 110 | + def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ... |
132 | 111 | @overload |
133 | | - def __rdivmod__(self, other: object, /) -> tuple[NAType, NAType]: ... |
| 112 | + def __rdivmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ... |
134 | 113 | @overload # type: ignore[override] |
135 | | - def __eq__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
| 114 | + def __eq__( # pyrefly: ignore[bad-override] |
136 | 115 | self, other: Series, / |
137 | 116 | ) -> Series[bool]: ... |
138 | 117 | @overload |
139 | | - def __eq__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] |
| 118 | + def __eq__(self, other: Index, /) -> BooleanArray: ... |
140 | 119 | @overload |
141 | 120 | def __eq__( # pyright: ignore[reportIncompatibleMethodOverride] |
142 | | - self, other: object, / |
| 121 | + self, other: Scalar, / |
143 | 122 | ) -> NAType: ... |
144 | 123 | @overload # type: ignore[override] |
145 | | - def __ne__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
| 124 | + def __ne__( # pyrefly: ignore[bad-override] |
146 | 125 | self, other: Series, / |
147 | 126 | ) -> Series[bool]: ... |
148 | 127 | @overload |
149 | | - def __ne__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] |
| 128 | + def __ne__(self, other: Index, /) -> BooleanArray: ... |
150 | 129 | @overload |
151 | 130 | def __ne__( # pyright: ignore[reportIncompatibleMethodOverride] |
152 | | - self, other: object, / |
| 131 | + self, other: Scalar, / |
153 | 132 | ) -> NAType: ... |
154 | 133 | @overload |
155 | | - def __le__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
156 | | - self, other: Series, / |
157 | | - ) -> Series[bool]: ... |
| 134 | + def __le__(self, other: Series, /) -> Series[bool]: ... |
158 | 135 | @overload |
159 | | - def __le__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] |
| 136 | + def __le__(self, other: Index, /) -> BooleanArray: ... |
160 | 137 | @overload |
161 | | - def __le__(self, other: object, /) -> NAType: ... |
| 138 | + def __le__(self, other: Scalar, /) -> NAType: ... |
162 | 139 | @overload |
163 | | - def __lt__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
164 | | - self, other: Series, / |
165 | | - ) -> Series[bool]: ... |
| 140 | + def __lt__(self, other: Series, /) -> Series[bool]: ... |
166 | 141 | @overload |
167 | | - def __lt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] |
| 142 | + def __lt__(self, other: Index, /) -> BooleanArray: ... |
168 | 143 | @overload |
169 | | - def __lt__(self, other: object, /) -> NAType: ... |
| 144 | + def __lt__(self, other: Scalar, /) -> NAType: ... |
170 | 145 | @overload |
171 | | - def __gt__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
172 | | - self, other: Series, / |
173 | | - ) -> Series[bool]: ... |
| 146 | + def __gt__(self, other: Series, /) -> Series[bool]: ... |
174 | 147 | @overload |
175 | | - def __gt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] |
| 148 | + def __gt__(self, other: Index, /) -> BooleanArray: ... |
176 | 149 | @overload |
177 | | - def __gt__(self, other: object, /) -> NAType: ... |
| 150 | + def __gt__(self, other: Scalar, /) -> NAType: ... |
178 | 151 | @overload |
179 | | - def __ge__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
180 | | - self, other: Series, / |
181 | | - ) -> Series[bool]: ... |
| 152 | + def __ge__(self, other: Series, /) -> Series[bool]: ... |
182 | 153 | @overload |
183 | | - def __ge__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] |
| 154 | + def __ge__(self, other: Index, /) -> BooleanArray: ... |
184 | 155 | @overload |
185 | | - def __ge__(self, other: object, /) -> NAType: ... |
| 156 | + def __ge__(self, other: Scalar, /) -> NAType: ... |
186 | 157 | def __neg__(self) -> NAType: ... |
187 | 158 | def __pos__(self) -> NAType: ... |
188 | 159 | def __abs__(self) -> NAType: ... |
189 | 160 | def __invert__(self) -> NAType: ... |
190 | 161 | @overload |
191 | | - def __pow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
192 | | - self, other: Series, / |
193 | | - ) -> Series: ... |
| 162 | + def __pow__(self, other: Series, /) -> Series: ... |
194 | 163 | @overload |
195 | | - def __pow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 164 | + def __pow__(self, other: Index, /) -> Index: ... |
196 | 165 | @overload |
197 | | - def __pow__(self, other: object, /) -> NAType: ... |
| 166 | + def __pow__(self, other: complex, /) -> NAType: ... |
198 | 167 | @overload |
199 | | - def __rpow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
200 | | - self, other: Series, / |
201 | | - ) -> Series: ... |
| 168 | + def __rpow__(self, other: Series, /) -> Series: ... |
202 | 169 | @overload |
203 | | - def __rpow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 170 | + def __rpow__(self, other: Index, /) -> Index: ... |
204 | 171 | @overload |
205 | | - def __rpow__(self, other: object, /) -> NAType: ... |
| 172 | + def __rpow__(self, other: complex, /) -> NAType: ... |
206 | 173 | @overload |
207 | | - def __and__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
| 174 | + def __and__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
208 | 175 | @overload |
209 | 176 | def __and__(self, other: bool | NAType, /) -> NAType: ... |
210 | 177 | @overload |
211 | | - def __rand__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
| 178 | + def __rand__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
212 | 179 | @overload |
213 | 180 | def __rand__(self, other: bool, /) -> NAType: ... |
214 | 181 | @overload |
215 | | - def __or__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
| 182 | + def __or__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
216 | 183 | @overload |
217 | 184 | def __or__(self, other: bool | NAType, /) -> NAType: ... |
218 | 185 | @overload |
219 | | - def __ror__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
| 186 | + def __ror__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
220 | 187 | @overload |
221 | 188 | def __ror__(self, other: bool | NAType, /) -> NAType: ... |
222 | 189 | @overload |
223 | | - def __xor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
224 | | - self, other: Series, / |
225 | | - ) -> Series: ... |
| 190 | + def __xor__(self, other: Series, /) -> Series: ... |
226 | 191 | @overload |
227 | | - def __xor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 192 | + def __xor__(self, other: Index, /) -> Index: ... |
228 | 193 | @overload |
229 | | - def __xor__(self, other: object, /) -> NAType: ... |
| 194 | + def __xor__(self, other: bool | np.bool, /) -> NAType: ... |
230 | 195 | @overload |
231 | | - def __rxor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] |
232 | | - self, other: Series, / |
233 | | - ) -> Series: ... |
| 196 | + def __rxor__(self, other: Series, /) -> Series: ... |
234 | 197 | @overload |
235 | | - def __rxor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] |
| 198 | + def __rxor__(self, other: Index, /) -> Index: ... |
236 | 199 | @overload |
237 | | - def __rxor__(self, other: object, /) -> NAType: ... |
| 200 | + def __rxor__(self, other: bool | np.bool, /) -> NAType: ... |
238 | 201 | __array_priority__: int |
239 | 202 | def __array_ufunc__( |
240 | 203 | self, ufunc: Callable[..., Any], method: str, *inputs: Any, **kwargs: Any |
|
0 commit comments