Skip to content

Commit 580d7c7

Browse files
authored
fix: pd.NAType (pandas-dev#1466)
* simplify missing * pyrefly * mypy + py310
1 parent 232b4a1 commit 580d7c7

File tree

3 files changed

+95
-132
lines changed

3 files changed

+95
-132
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ci:
33
autofix_prs: false
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.14.2
6+
rev: v0.14.3
77
hooks:
88
- id: ruff-check
99
args: [--exit-non-zero-on-fix]
@@ -14,7 +14,7 @@ repos:
1414
additional_dependencies: [ tomli ]
1515
args: [-L, "THIRDPARTY"]
1616
- repo: https://github.com/PyCQA/isort
17-
rev: 6.0.1
17+
rev: 7.0.0
1818
hooks:
1919
- id: isort
2020
- repo: https://github.com/psf/black

pandas-stubs/_libs/missing.pyi

Lines changed: 90 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,240 +1,203 @@
11
from collections.abc import Callable
2+
import sys
23
from typing import (
34
Any,
45
Literal,
56
overload,
67
)
78

8-
from pandas import (
9-
Index,
10-
Series,
11-
)
9+
import numpy as np
1210
from pandas.core.arrays.boolean import BooleanArray
11+
from pandas.core.indexes.base import Index
12+
from pandas.core.series import Series
1313
from typing_extensions import Self
1414

15+
from pandas._typing import Scalar
16+
1517
class NAType:
1618
def __new__(cls, *args: Any, **kwargs: Any) -> Self: ...
1719
def __format__(self, format_spec: str) -> str: ...
1820
def __hash__(self) -> int: ...
1921
def __reduce__(self) -> str: ...
2022
@overload
21-
def __add__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
22-
self, other: Series, /
23-
) -> Series: ...
23+
def __add__(self, other: Series, /) -> Series: ...
2424
@overload
25-
def __add__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
25+
def __add__(self, other: Index, /) -> Index: ...
2626
@overload
27-
def __add__(self, other: object, /) -> NAType: ...
27+
def __add__(self, other: Scalar, /) -> NAType: ...
2828
@overload
29-
def __radd__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
30-
self, other: Series, /
31-
) -> Series: ...
29+
def __radd__(self, other: Series, /) -> Series: ...
3230
@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+
3439
@overload
35-
def __radd__(self, other: object, /) -> NAType: ...
40+
def __sub__(self, other: Series, /) -> Series: ...
3641
@overload
37-
def __sub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
38-
self, other: Series, /
39-
) -> Series: ...
42+
def __sub__(self, other: Index, /) -> Index: ...
4043
@overload
41-
def __sub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
44+
def __sub__(self, other: Scalar, /) -> NAType: ...
4245
@overload
43-
def __sub__(self, other: object, /) -> NAType: ...
46+
def __rsub__(self, other: Series, /) -> Series: ...
4447
@overload
45-
def __rsub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
46-
self, other: Series, /
47-
) -> Series: ...
48+
def __rsub__(self, other: Index, /) -> Index: ...
4849
@overload
49-
def __rsub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
50+
def __rsub__(self, other: Scalar, /) -> NAType: ...
5051
@overload
51-
def __rsub__(self, other: object, /) -> NAType: ...
52+
def __mul__(self, other: Series, /) -> Series: ...
5253
@overload
53-
def __mul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
54-
self, other: Series, /
55-
) -> Series: ...
54+
def __mul__(self, other: Index, /) -> Index: ...
5655
@overload
57-
def __mul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
56+
def __mul__(self, other: Scalar, /) -> NAType: ...
5857
@overload
59-
def __mul__(self, other: object, /) -> NAType: ...
58+
def __rmul__(self, other: Series, /) -> Series: ...
6059
@overload
61-
def __rmul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
62-
self, other: Series, /
63-
) -> Series: ...
60+
def __rmul__(self, other: Index, /) -> Index: ...
6461
@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: ...
6665
@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: ...
7067
@overload
71-
def __truediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
72-
self, other: Series, /
73-
) -> Series: ...
68+
def __truediv__(self, other: Index, /) -> Index: ...
7469
@overload
75-
def __truediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
70+
def __truediv__(self, other: Scalar, /) -> NAType: ...
7671
@overload
77-
def __truediv__(self, other: object, /) -> NAType: ...
72+
def __rtruediv__(self, other: Series, /) -> Series: ...
7873
@overload
79-
def __rtruediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
80-
self, other: Series, /
81-
) -> Series: ...
74+
def __rtruediv__(self, other: Index, /) -> Index: ...
8275
@overload
83-
def __rtruediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
76+
def __rtruediv__(self, other: Scalar, /) -> NAType: ...
8477
@overload
85-
def __rtruediv__(self, other: object, /) -> NAType: ...
78+
def __floordiv__(self, other: Series, /) -> Series: ...
8679
@overload
87-
def __floordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
88-
self, other: Series, /
89-
) -> Series: ...
80+
def __floordiv__(self, other: Index, /) -> Index: ...
9081
@overload
91-
def __floordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
82+
def __floordiv__(self, other: Scalar, /) -> NAType: ...
9283
@overload
93-
def __floordiv__(self, other: object, /) -> NAType: ...
84+
def __rfloordiv__(self, other: Series, /) -> Series: ...
9485
@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: ...
10087
@overload
101-
def __rfloordiv__(self, other: object, /) -> NAType: ...
88+
def __rfloordiv__(self, other: Scalar, /) -> NAType: ...
10289
@overload
103-
def __mod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
104-
self, other: Series, /
105-
) -> Series: ...
90+
def __mod__(self, other: Series, /) -> Series: ...
10691
@overload
107-
def __mod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
92+
def __mod__(self, other: Index, /) -> Index: ...
10893
@overload
109-
def __mod__(self, other: object, /) -> NAType: ...
94+
def __mod__(self, other: Scalar, /) -> NAType: ...
11095
@overload
111-
def __rmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
112-
self, other: Series, /
113-
) -> Series: ...
96+
def __rmod__(self, other: Series, /) -> Series: ...
11497
@overload
115-
def __rmod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
98+
def __rmod__(self, other: Index, /) -> Index: ...
11699
@overload
117-
def __rmod__(self, other: object, /) -> NAType: ...
100+
def __rmod__(self, other: Scalar, /) -> NAType: ...
118101
@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]: ...
122103
@overload
123-
def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap]
104+
def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ...
124105
@overload
125-
def __divmod__(self, other: object, /) -> tuple[NAType, NAType]: ...
106+
def __divmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ...
126107
@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]: ...
130109
@overload
131-
def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap]
110+
def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ...
132111
@overload
133-
def __rdivmod__(self, other: object, /) -> tuple[NAType, NAType]: ...
112+
def __rdivmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ...
134113
@overload # type: ignore[override]
135-
def __eq__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
114+
def __eq__( # pyrefly: ignore[bad-override]
136115
self, other: Series, /
137116
) -> Series[bool]: ...
138117
@overload
139-
def __eq__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap]
118+
def __eq__(self, other: Index, /) -> BooleanArray: ...
140119
@overload
141120
def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
142-
self, other: object, /
121+
self, other: Scalar, /
143122
) -> NAType: ...
144123
@overload # type: ignore[override]
145-
def __ne__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
124+
def __ne__( # pyrefly: ignore[bad-override]
146125
self, other: Series, /
147126
) -> Series[bool]: ...
148127
@overload
149-
def __ne__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap]
128+
def __ne__(self, other: Index, /) -> BooleanArray: ...
150129
@overload
151130
def __ne__( # pyright: ignore[reportIncompatibleMethodOverride]
152-
self, other: object, /
131+
self, other: Scalar, /
153132
) -> NAType: ...
154133
@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]: ...
158135
@overload
159-
def __le__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap]
136+
def __le__(self, other: Index, /) -> BooleanArray: ...
160137
@overload
161-
def __le__(self, other: object, /) -> NAType: ...
138+
def __le__(self, other: Scalar, /) -> NAType: ...
162139
@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]: ...
166141
@overload
167-
def __lt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap]
142+
def __lt__(self, other: Index, /) -> BooleanArray: ...
168143
@overload
169-
def __lt__(self, other: object, /) -> NAType: ...
144+
def __lt__(self, other: Scalar, /) -> NAType: ...
170145
@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]: ...
174147
@overload
175-
def __gt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap]
148+
def __gt__(self, other: Index, /) -> BooleanArray: ...
176149
@overload
177-
def __gt__(self, other: object, /) -> NAType: ...
150+
def __gt__(self, other: Scalar, /) -> NAType: ...
178151
@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]: ...
182153
@overload
183-
def __ge__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap]
154+
def __ge__(self, other: Index, /) -> BooleanArray: ...
184155
@overload
185-
def __ge__(self, other: object, /) -> NAType: ...
156+
def __ge__(self, other: Scalar, /) -> NAType: ...
186157
def __neg__(self) -> NAType: ...
187158
def __pos__(self) -> NAType: ...
188159
def __abs__(self) -> NAType: ...
189160
def __invert__(self) -> NAType: ...
190161
@overload
191-
def __pow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
192-
self, other: Series, /
193-
) -> Series: ...
162+
def __pow__(self, other: Series, /) -> Series: ...
194163
@overload
195-
def __pow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
164+
def __pow__(self, other: Index, /) -> Index: ...
196165
@overload
197-
def __pow__(self, other: object, /) -> NAType: ...
166+
def __pow__(self, other: complex, /) -> NAType: ...
198167
@overload
199-
def __rpow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
200-
self, other: Series, /
201-
) -> Series: ...
168+
def __rpow__(self, other: Series, /) -> Series: ...
202169
@overload
203-
def __rpow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
170+
def __rpow__(self, other: Index, /) -> Index: ...
204171
@overload
205-
def __rpow__(self, other: object, /) -> NAType: ...
172+
def __rpow__(self, other: complex, /) -> NAType: ...
206173
@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]
208175
@overload
209176
def __and__(self, other: bool | NAType, /) -> NAType: ...
210177
@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]
212179
@overload
213180
def __rand__(self, other: bool, /) -> NAType: ...
214181
@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]
216183
@overload
217184
def __or__(self, other: bool | NAType, /) -> NAType: ...
218185
@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]
220187
@overload
221188
def __ror__(self, other: bool | NAType, /) -> NAType: ...
222189
@overload
223-
def __xor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
224-
self, other: Series, /
225-
) -> Series: ...
190+
def __xor__(self, other: Series, /) -> Series: ...
226191
@overload
227-
def __xor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
192+
def __xor__(self, other: Index, /) -> Index: ...
228193
@overload
229-
def __xor__(self, other: object, /) -> NAType: ...
194+
def __xor__(self, other: bool | np.bool, /) -> NAType: ...
230195
@overload
231-
def __rxor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
232-
self, other: Series, /
233-
) -> Series: ...
196+
def __rxor__(self, other: Series, /) -> Series: ...
234197
@overload
235-
def __rxor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap]
198+
def __rxor__(self, other: Index, /) -> Index: ...
236199
@overload
237-
def __rxor__(self, other: object, /) -> NAType: ...
200+
def __rxor__(self, other: bool | np.bool, /) -> NAType: ...
238201
__array_priority__: int
239202
def __array_ufunc__(
240203
self, ufunc: Callable[..., Any], method: str, *inputs: Any, **kwargs: Any

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ pyarrow = ">=10.0.1"
4343
pytest = ">=8.4.2"
4444
pyright = ">=1.1.407"
4545
ty = "0.0.1a25"
46-
pyrefly = ">=0.38.2"
46+
pyrefly = ">=0.39.4"
4747
poethepoet = ">=0.16.5"
4848
loguru = ">=0.6.0"
4949
typing-extensions = ">=4.4.0"
5050
matplotlib = ">=3.10.1"
51-
pre-commit = ">=2.19.0"
51+
pre-commit = ">=4.3.0"
5252
black = ">=25.9.0"
53-
isort = ">=6.0.1"
53+
isort = ">=7.0.0"
5454
openpyxl = ">=3.0.10"
5555
numexpr = ">=2.13.1"
5656
lxml = ">=4.9.1"

0 commit comments

Comments
 (0)