Skip to content

Commit 2d42ecd

Browse files
committed
Merge branch 'main' of github.com:pandas-dev/pandas-stubs into feature/cmp0xff/truediv
2 parents 1ea5826 + 58de93c commit 2d42ecd

File tree

4 files changed

+65
-53
lines changed

4 files changed

+65
-53
lines changed

pandas-stubs/core/base.pyi

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ from pandas._libs.tslibs.timedeltas import Timedelta
2929
from pandas._typing import (
3030
S1,
3131
S2,
32-
ArrayLike,
3332
AxisIndex,
3433
DropKeep,
3534
DTypeLike,
3635
GenericT,
3736
GenericT_co,
3837
Just,
38+
ListLike,
3939
NDFrameT,
4040
Scalar,
41-
SequenceNotStr,
4241
SupportsDType,
4342
np_1darray,
4443
np_ndarray_anyint,
@@ -48,8 +47,6 @@ from pandas._typing import (
4847
)
4948
from pandas.util._decorators import cache_readonly
5049

51-
_ListLike: TypeAlias = ArrayLike | dict[str, np.ndarray] | SequenceNotStr[S1]
52-
5350
class NoNewAttributesMixin:
5451
def __setattr__(self, key: str, value: Any) -> None: ...
5552

@@ -158,16 +155,16 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
158155
@overload
159156
def searchsorted(
160157
self,
161-
value: _ListLike,
158+
value: ListLike,
162159
side: Literal["left", "right"] = ...,
163-
sorter: _ListLike | None = ...,
160+
sorter: ListLike | None = None,
164161
) -> np_1darray[np.intp]: ...
165162
@overload
166163
def searchsorted(
167164
self,
168165
value: Scalar,
169166
side: Literal["left", "right"] = ...,
170-
sorter: _ListLike | None = ...,
167+
sorter: ListLike | None = None,
171168
) -> np.intp: ...
172169
def drop_duplicates(self, *, keep: DropKeep = ...) -> Self: ...
173170

pandas-stubs/core/indexes/base.pyi

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ from pandas.core.base import (
4949
Supports_ProtoRMul,
5050
Supports_ProtoRTrueDiv,
5151
Supports_ProtoTrueDiv,
52-
_ListLike,
5352
)
5453
from pandas.core.indexes.category import CategoricalIndex
5554
from pandas.core.strings.accessor import StringMethods
@@ -508,7 +507,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
508507
@overload
509508
def __add__(self: Index[Never], other: _str) -> Never: ...
510509
@overload
511-
def __add__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
510+
def __add__(
511+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
512+
) -> Index: ...
512513
@overload
513514
def __add__(self, other: Index[Never]) -> Index: ...
514515
@overload
@@ -560,7 +561,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
560561
@overload
561562
def __radd__(self: Index[Never], other: _str) -> Never: ...
562563
@overload
563-
def __radd__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
564+
def __radd__(
565+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
566+
) -> Index: ...
564567
@overload
565568
def __radd__(self: Index[Never], other: Period) -> PeriodIndex: ...
566569
@overload
@@ -611,7 +614,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
611614
@overload
612615
def __sub__(self: Index[Never], other: DatetimeIndex) -> Never: ...
613616
@overload
614-
def __sub__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
617+
def __sub__(
618+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
619+
) -> Index: ...
615620
@overload
616621
def __sub__(self, other: Index[Never]) -> Index: ...
617622
@overload
@@ -680,7 +685,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
680685
@overload
681686
def __rsub__(self: Index[Never], other: DatetimeIndex) -> Never: ... # type: ignore[misc]
682687
@overload
683-
def __rsub__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
688+
def __rsub__(
689+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
690+
) -> Index: ...
684691
@overload
685692
def __rsub__(self, other: Index[Never]) -> Index: ...
686693
@overload
@@ -747,7 +754,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
747754
),
748755
) -> Index[complex]: ...
749756
@overload
750-
def __mul__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
757+
def __mul__(
758+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
759+
) -> Index: ...
751760
@overload
752761
def __mul__(self, other: Index[Never]) -> Index: ...
753762
@overload
@@ -823,7 +832,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
823832
self: Index[T_COMPLEX], other: np_ndarray_complex | Index[complex]
824833
) -> Index[complex]: ...
825834
@overload
826-
def __rmul__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
835+
def __rmul__(
836+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
837+
) -> Index: ...
827838
@overload
828839
def __rmul__(self, other: Index[Never]) -> Index: ...
829840
@overload
@@ -901,7 +912,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
901912
) -> Index[complex]: ...
902913
@overload
903914
def __truediv__(
904-
self: Index[Never], other: complex | _ListLike | Index
915+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
905916
) -> Index: ...
906917
@overload
907918
def __truediv__(self, other: Index[Never]) -> Index: ...
@@ -980,7 +991,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
980991
def __truediv__(self, other: Path) -> Index: ...
981992
@overload
982993
def __rtruediv__(
983-
self: Index[Never], other: complex | _ListLike | Index
994+
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
984995
) -> Index: ...
985996
@overload
986997
def __rtruediv__(self, other: Index[Never]) -> Index: ...

pandas-stubs/core/series.pyi

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ from pandas.core.base import (
7474
Supports_ProtoRMul,
7575
Supports_ProtoRTrueDiv,
7676
Supports_ProtoTrueDiv,
77-
_ListLike,
7877
)
7978
from pandas.core.frame import DataFrame
8079
from pandas.core.generic import NDFrame
@@ -297,7 +296,8 @@ class _LocIndexerSeries(_LocIndexer, Generic[S1]):
297296
value: S1 | ArrayLike | Series[S1] | None,
298297
) -> None: ...
299298

300-
_ListLikeS1: TypeAlias = (
299+
_DataLike: TypeAlias = ArrayLike | dict[str, np.ndarray] | SequenceNotStr[S1]
300+
_DataLikeS1: TypeAlias = (
301301
ArrayLike | dict[_str, np.ndarray] | Sequence[S1] | IndexOpsMixin[S1]
302302
)
303303

@@ -361,7 +361,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
361361
@overload
362362
def __new__(
363363
cls,
364-
data: _ListLike,
364+
data: _DataLike,
365365
index: AxesData | None = ...,
366366
*,
367367
dtype: TimestampDtypeArg,
@@ -371,7 +371,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
371371
@overload
372372
def __new__(
373373
cls,
374-
data: _ListLike,
374+
data: _DataLike,
375375
index: AxesData | None = ...,
376376
*,
377377
dtype: CategoryDtypeArg,
@@ -428,7 +428,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
428428
@overload
429429
def __new__( # type: ignore[overload-overlap]
430430
cls,
431-
data: Scalar | _ListLike | dict[HashableT1, Any] | None,
431+
data: Scalar | _DataLike | dict[HashableT1, Any] | None,
432432
index: AxesData | None = ...,
433433
*,
434434
dtype: type[S1],
@@ -475,7 +475,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
475475
def __new__(
476476
cls,
477477
data: (
478-
S1 | _ListLikeS1[S1] | dict[HashableT1, S1] | KeysView[S1] | ValuesView[S1]
478+
S1 | _DataLikeS1[S1] | dict[HashableT1, S1] | KeysView[S1] | ValuesView[S1]
479479
),
480480
index: AxesData | None = ...,
481481
dtype: Dtype = ...,
@@ -487,7 +487,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
487487
cls,
488488
data: (
489489
Scalar
490-
| _ListLike
490+
| _DataLike
491491
| Mapping[HashableT1, Any]
492492
| BaseGroupBy
493493
| NaTType
@@ -854,7 +854,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
854854
@overload
855855
def quantile(
856856
self,
857-
q: _ListLike,
857+
q: ListLike,
858858
interpolation: QuantileInterpolation = ...,
859859
) -> Series[S1]: ...
860860
def corr(
@@ -906,16 +906,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
906906
@overload
907907
def searchsorted(
908908
self,
909-
value: _ListLike,
909+
value: ListLike,
910910
side: Literal["left", "right"] = ...,
911-
sorter: _ListLike | None = ...,
911+
sorter: ListLike | None = None,
912912
) -> np_1darray[np.intp]: ...
913913
@overload
914914
def searchsorted(
915915
self,
916916
value: Scalar,
917917
side: Literal["left", "right"] = ...,
918-
sorter: _ListLike | None = ...,
918+
sorter: ListLike | None = None,
919919
) -> np.intp: ...
920920
@overload
921921
def compare(
@@ -1312,7 +1312,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
13121312
) -> Series[S1]: ...
13131313
def filter(
13141314
self,
1315-
items: _ListLike | None = None,
1315+
items: ListLike | None = None,
13161316
like: _str | None = None,
13171317
regex: _str | None = None,
13181318
axis: AxisIndex | None = None,
@@ -1327,7 +1327,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
13271327
n: int | None = None,
13281328
frac: float | None = None,
13291329
replace: _bool = False,
1330-
weights: _str | _ListLike | np.ndarray | None = None,
1330+
weights: _str | ListLike | np.ndarray | None = None,
13311331
random_state: RandomState | None = None,
13321332
axis: AxisIndex | None = None,
13331333
ignore_index: _bool = False,
@@ -1688,9 +1688,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
16881688
# just failed to generate these so I couldn't match
16891689
# them up.
16901690
@overload
1691-
def __add__(
1692-
self: Series[Never], other: complex | _ListLike | Index | Series
1693-
) -> Series: ...
1691+
def __add__(self: Series[Never], other: complex | ListLike) -> Series: ...
16941692
@overload
16951693
def __add__(self, other: Index[Never] | Series[Never]) -> Series: ...
16961694
@overload
@@ -1776,7 +1774,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
17761774
@overload
17771775
def add(
17781776
self: Series[Never],
1779-
other: complex | _ListLike | Index | Series,
1777+
other: complex | ListLike,
17801778
level: Level | None = None,
17811779
fill_value: float | None = None,
17821780
axis: int = 0,
@@ -1907,9 +1905,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
19071905
axis: int = 0,
19081906
) -> Series[_str]: ...
19091907
@overload
1910-
def __radd__(
1911-
self: Series[Never], other: complex | _ListLike | Index | Series
1912-
) -> Series: ...
1908+
def __radd__(self: Series[Never], other: complex | ListLike) -> Series: ...
19131909
@overload
19141910
def __radd__(self, other: Index[Never] | Series[Never]) -> Series: ...
19151911
@overload
@@ -2009,7 +2005,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
20092005
@overload
20102006
def radd(
20112007
self: Series[Never],
2012-
other: complex | _ListLike | Index | Series,
2008+
other: complex | ListLike,
20132009
level: Level | None = None,
20142010
fill_value: float | None = None,
20152011
axis: int = 0,
@@ -2462,16 +2458,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
24622458
axis: AxisIndex = ...,
24632459
) -> Series[int]: ...
24642460
def __ge__( # type: ignore[override]
2465-
self, other: S1 | _ListLike | Series[S1] | datetime | timedelta | date
2461+
self, other: S1 | ListLike | Series[S1] | datetime | timedelta | date
24662462
) -> Series[_bool]: ...
24672463
def __gt__( # type: ignore[override]
2468-
self, other: S1 | _ListLike | Series[S1] | datetime | timedelta | date
2464+
self, other: S1 | ListLike | Series[S1] | datetime | timedelta | date
24692465
) -> Series[_bool]: ...
24702466
def __le__( # type: ignore[override]
2471-
self, other: S1 | _ListLike | Series[S1] | datetime | timedelta | date
2467+
self, other: S1 | ListLike | Series[S1] | datetime | timedelta | date
24722468
) -> Series[_bool]: ...
24732469
def __lt__( # type: ignore[override]
2474-
self, other: S1 | _ListLike | Series[S1] | datetime | timedelta | date
2470+
self, other: S1 | ListLike | Series[S1] | datetime | timedelta | date
24752471
) -> Series[_bool]: ...
24762472
@overload
24772473
def __mul__( # type: ignore[overload-overlap]
@@ -2568,7 +2564,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
25682564
@overload
25692565
def mul(
25702566
self: Series[Never],
2571-
other: complex | _ListLike | Index | Series,
2567+
other: complex | ListLike,
25722568
level: Level | None = None,
25732569
fill_value: float | None = None,
25742570
axis: int = 0,
@@ -2778,7 +2774,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
27782774
@overload
27792775
def rmul(
27802776
self: Series[Never],
2781-
other: complex | _ListLike | Index | Series,
2777+
other: complex | ListLike,
27822778
level: Level | None = None,
27832779
fill_value: float | None = None,
27842780
axis: int = 0,
@@ -2893,9 +2889,9 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
28932889
fill_value: float | None = None,
28942890
axis: int = 0,
28952891
) -> Series[complex]: ...
2896-
def __mod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
2892+
def __mod__(self, other: num | ListLike | Series[S1]) -> Series[S1]: ...
28972893
def __ne__(self, other: object) -> Series[_bool]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
2898-
def __pow__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
2894+
def __pow__(self, other: num | ListLike | Series[S1]) -> Series[S1]: ...
28992895
# ignore needed for mypy as we want different results based on the arguments
29002896
@overload # type: ignore[override]
29012897
# pyrefly: ignore # bad-override
@@ -2912,9 +2908,9 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
29122908
) -> Series[bool]: ...
29132909
@overload
29142910
def __rand__(self, other: int | np_ndarray_anyint | Series[int]) -> Series[int]: ...
2915-
def __rdivmod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
2916-
def __rmod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
2917-
def __rpow__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
2911+
def __rdivmod__(self, other: num | ListLike | Series[S1]) -> Series[S1]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
2912+
def __rmod__(self, other: num | ListLike | Series[S1]) -> Series[S1]: ...
2913+
def __rpow__(self, other: num | ListLike | Series[S1]) -> Series[S1]: ...
29182914
# ignore needed for mypy as we want different results based on the arguments
29192915
@overload # type: ignore[override]
29202916
# pyrefly: ignore # bad-override
@@ -3674,7 +3670,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
36743670
@overload
36753671
def truediv(
36763672
self: Series[Never],
3677-
other: complex | _ListLike | Index | Series,
3673+
other: complex | ListLike,
36783674
level: Level | None = None,
36793675
fill_value: float | None = None,
36803676
axis: AxisIndex = 0,
@@ -3924,7 +3920,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
39243920
@overload
39253921
def rtruediv(
39263922
self: Series[Never],
3927-
other: complex | _ListLike | Index | Series,
3923+
other: complex | ListLike,
39283924
level: Level | None = None,
39293925
fill_value: float | None = None,
39303926
axis: AxisIndex = 0,
@@ -4146,7 +4142,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
41464142
) -> Series[S1]: ...
41474143
def divmod(
41484144
self,
4149-
other: num | _ListLike | Series[S1],
4145+
other: num | ListLike | Series[S1],
41504146
level: Level | None = ...,
41514147
fill_value: float | None = None,
41524148
axis: AxisIndex = ...,
@@ -4304,7 +4300,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
43044300
) -> S1: ...
43054301
def mod(
43064302
self,
4307-
other: num | _ListLike | Series[S1],
4303+
other: num | ListLike | Series[S1],
43084304
level: Level | None = ...,
43094305
fill_value: float | None = None,
43104306
axis: AxisIndex | None = 0,
@@ -4320,7 +4316,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
43204316
def nunique(self, dropna: _bool = True) -> int: ...
43214317
def pow(
43224318
self,
4323-
other: num | _ListLike | Series[S1],
4319+
other: num | ListLike | Series[S1],
43244320
level: Level | None = ...,
43254321
fill_value: float | None = None,
43264322
axis: AxisIndex | None = 0,

0 commit comments

Comments
 (0)