Skip to content

Commit f10e990

Browse files
committed
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
2 parents 3ff2c36 + 5099a1a commit f10e990

File tree

14 files changed

+513
-80
lines changed

14 files changed

+513
-80
lines changed

docs/philosophy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ and `tags`, are recognized by type checkers as `Series[Any]`. The code snippet
9595
runs fine at runtime. In the stub for type checking, however, we restrict
9696
generic Series to perform arithmetic operations only with numeric types, and
9797
give `Series[Any]` for the results. For `Timedelta`, `Timestamp`, `str`, etc.,
98-
arithmetic is restricted to `Series[Any]` and the result is either undefined,
98+
arithmetic is restricted to `Series[Any]` and the result is either undefined,
9999
showing `Unknown` and errors, or `Never`. Users are encouraged to cast such
100100
generic Series to ones with concrete types, so that type checkers can provide
101101
meaningful results.

pandas-stubs/_libs/missing.pyi

Lines changed: 234 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,243 @@
1+
from typing import (
2+
Any,
3+
Callable,
4+
Literal,
5+
overload,
6+
)
7+
8+
from pandas import (
9+
Index,
10+
Series,
11+
)
12+
from pandas.core.arrays.boolean import BooleanArray
113
from typing_extensions import Self
214

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

46243
NA: NAType = ...

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class Timestamp(datetime, SupportsIndex):
238238
) -> np_ndarray[ShapeT, np.datetime64]: ...
239239
# TODO: test dt64
240240
@overload # type: ignore[override]
241-
def __sub__(self, other: Timestamp | datetime | np.datetime64) -> Timedelta: ...
241+
def __sub__(self, other: datetime | np.datetime64) -> Timedelta: ...
242242
@overload
243243
def __sub__(self, other: timedelta | np.timedelta64 | Tick) -> Self: ...
244244
@overload

pandas-stubs/core/generic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,6 @@ class NDFrame(indexing.IndexingMixin):
430430
origin: TimeGrouperOrigin | TimestampConvertibleTypes = "start_day",
431431
offset: TimedeltaConvertibleTypes | None = None,
432432
group_keys: _bool = False,
433-
) -> DatetimeIndexResampler[Self]: ...
433+
) -> DatetimeIndexResampler[Self]: ... # pyrefly: ignore[bad-specialization]
434434
@final
435435
def take(self, indices: TakeIndexer, axis: Axis = 0, **kwargs: Any) -> Self: ...

pandas-stubs/core/groupby/generic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class DFCallable3(Protocol[P]): # ty: ignore[invalid-argument-type]
229229
class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT, _TT]):
230230
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
231231
@overload # type: ignore[override]
232-
def apply(
232+
def apply( # pyrefly: ignore[bad-override]
233233
self,
234234
func: DFCallable1[P],
235235
/,

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ class GroupBy(BaseGroupBy[NDFrameT]):
255255
def bfill(self, limit: int | None = ...) -> NDFrameT: ...
256256
@final
257257
@property
258-
def nth(self) -> GroupByNthSelector[Self]: ...
258+
def nth(
259+
self,
260+
) -> GroupByNthSelector[Self]: ... # pyrefly: ignore[bad-specialization]
259261
@final
260262
def quantile(
261263
self,

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class Index(IndexOpsMixin[S1]):
279279
@property
280280
def str(
281281
self,
282-
) -> StringMethods[
282+
) -> StringMethods[ # pyrefly: ignore[bad-specialization]
283283
Self,
284284
MultiIndex,
285285
np_1darray[np.bool],

pandas-stubs/core/series.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
12051205
@property
12061206
def str(
12071207
self,
1208-
) -> StringMethods[
1208+
) -> StringMethods[ # pyrefly: ignore[bad-specialization]
12091209
Self,
12101210
DataFrame,
12111211
Series[bool],
@@ -4163,7 +4163,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
41634163
) -> _T: ...
41644164
def to_list(self) -> list[S1]: ...
41654165
@overload # type: ignore[override]
4166-
def to_numpy(
4166+
def to_numpy( # pyrefly: ignore[bad-override]
41674167
self: Series[Timestamp],
41684168
dtype: None = None,
41694169
copy: bool = False,

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ pandas = "2.3.2"
4141
pyarrow = ">=10.0.1"
4242
pytest = ">=7.1.2"
4343
pyright = ">=1.1.405"
44-
ty = "^0.0.1a20"
45-
pyrefly = "^0.21.0"
44+
ty = ">=0.0.1a20"
45+
pyrefly = ">=0.32.0"
4646
poethepoet = ">=0.16.5"
4747
loguru = ">=0.6.0"
4848
typing-extensions = ">=4.4.0"
4949
matplotlib = ">=3.10.1"
5050
pre-commit = ">=2.19.0"
51-
black = ">=23.3.0"
52-
isort = ">=5.12.0"
51+
black = ">=25.1.0"
52+
isort = ">=6.0.1"
5353
openpyxl = ">=3.0.10"
5454
tables = { version = ">=3.10.1", python = "<4" }
5555
lxml = ">=4.9.1"

tests/test_dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_categorical_dtype() -> None:
113113
pd.CategoricalDtype,
114114
)
115115
check(assert_type(cdt.categories, pd.Index), pd.Index)
116-
assert check(assert_type(cdt.ordered, Optional[bool]), bool)
116+
check(assert_type(cdt.ordered, Optional[bool]), bool)
117117

118118

119119
def test_sparse_dtype() -> None:

0 commit comments

Comments
 (0)