@@ -83,6 +83,12 @@ from pandas.core.groupby.generic import SeriesGroupBy
8383from pandas .core .groupby .groupby import BaseGroupBy
8484from pandas .core .indexers import BaseIndexer
8585from pandas .core .indexes .accessors import DtDescriptor
86+ from pandas .core .indexes .base import (
87+ ArrayIndexTimedeltaNoSeq ,
88+ ScalarArrayIndexComplex ,
89+ ScalarArrayIndexReal ,
90+ ScalarArrayIndexTimedelta ,
91+ )
8692from pandas .core .indexes .category import CategoricalIndex
8793from pandas .core .indexes .datetimes import DatetimeIndex
8894from pandas .core .indexes .interval import IntervalIndex
@@ -302,30 +308,15 @@ _DataLike: TypeAlias = ArrayLike | dict[str, np.ndarray] | SequenceNotStr[S1]
302308_DataLikeS1 : TypeAlias = (
303309 ArrayLike | dict [_str , np .ndarray ] | Sequence [S1 ] | IndexOpsMixin [S1 ]
304310)
305- _OtherFloorDivNumPyGeneric : TypeAlias = np .bool | np .integer | np .floating
306- _OtherFloorDiv : TypeAlias = (
307- float
308- | _OtherFloorDivNumPyGeneric
309- | Sequence [float | _OtherFloorDivNumPyGeneric ]
310- | np_ndarray [tuple [int , ...], _OtherFloorDivNumPyGeneric ]
311- | Index [bool ]
312- | Index [int ]
313- | Index [float ]
314- | Series [bool ]
315- | Series [int ]
316- | Series [float ]
317- )
318- _OtherTrueDivNumPyGeneric : TypeAlias = _OtherFloorDivNumPyGeneric | np .complex128
319- _OtherTrueDiv : TypeAlias = (
320- _OtherFloorDiv
321- | complex
322- | _OtherTrueDivNumPyGeneric
323- | Sequence [complex | _OtherTrueDivNumPyGeneric ]
324- | np_ndarray_complex
325- | Index [complex ]
326- | Series [complex ]
311+
312+ SeriesReal : TypeAlias = Series [bool ] | Series [int ] | Series [float ] # ty: ignore[unresolved-reference]
313+ ScalarArrayIndexSeriesReal : TypeAlias = ScalarArrayIndexReal | SeriesReal
314+ SeriesComplex : TypeAlias = SeriesReal | Series [complex ] # ty: ignore[unresolved-reference]
315+ ScalarArrayIndexSeriesComplex : TypeAlias = ScalarArrayIndexComplex | SeriesComplex
316+ ArrayIndexSeriesTimedeltaNoSeq : TypeAlias = ArrayIndexTimedeltaNoSeq | Series [Timedelta ] # ty: ignore[unresolved-reference]
317+ ScalarArrayIndexSeriesTimedelta : TypeAlias = (
318+ ScalarArrayIndexTimedelta | Series [Timedelta ] # ty: ignore[unresolved-reference]
327319)
328- _OtherRTrueDiv : TypeAlias = _OtherTrueDiv
329320
330321class Series (IndexOpsMixin [S1 ], ElementOpsMixin [S1 ], NDFrame ):
331322 # Define __index__ because mypy thinks Series follows protocol `SupportsIndex` https://github.com/pandas-dev/pandas-stubs/pull/1332#discussion_r2285648790
@@ -2183,7 +2174,9 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
21832174 other : np_ndarray_complex | np_ndarray_dt | np_ndarray_td ,
21842175 ) -> Never : ...
21852176 @overload
2186- def __floordiv__ (self : Series [Never ], other : _OtherFloorDiv ) -> Series : ...
2177+ def __floordiv__ (
2178+ self : Series [Never ], other : ScalarArrayIndexSeriesReal
2179+ ) -> Series : ...
21872180 @overload
21882181 def __floordiv__ (
21892182 self : Series [bool ] | Series [int ] | Series [float ] | Series [Timedelta ],
@@ -2244,8 +2237,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
22442237 ) -> Series [Timedelta ]: ...
22452238 @overload
22462239 def __floordiv__ (
2247- self : Series [Timedelta ],
2248- other : np_ndarray_td | TimedeltaIndex | Series [Timedelta ],
2240+ self : Series [Timedelta ], other : ArrayIndexSeriesTimedeltaNoSeq
22492241 ) -> Series [int ]: ...
22502242 @overload
22512243 def floordiv (
@@ -2258,7 +2250,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
22582250 @overload
22592251 def floordiv (
22602252 self : Series [Never ],
2261- other : _OtherFloorDiv ,
2253+ other : ScalarArrayIndexSeriesReal ,
22622254 level : Level | None = ...,
22632255 fill_value : float | None = None ,
22642256 axis : AxisIndex | None = 0 ,
@@ -2342,27 +2334,14 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
23422334 @overload
23432335 def floordiv (
23442336 self : Series [Timedelta ],
2345- other : np_ndarray_td | TimedeltaIndex | Series [ Timedelta ] ,
2337+ other : ArrayIndexSeriesTimedeltaNoSeq ,
23462338 level : Level | None = ...,
23472339 fill_value : float | None = None ,
23482340 axis : AxisIndex | None = 0 ,
23492341 ) -> Series [int ]: ...
23502342 @overload
2351- def __rfloordiv__ ( # type: ignore[overload-overlap]
2352- self : Series [Never ],
2353- other : (
2354- float
2355- | Sequence [float ]
2356- | np_ndarray_bool
2357- | np_ndarray_anyint
2358- | np_ndarray_float
2359- | Index [bool ]
2360- | Index [int ]
2361- | Index [float ]
2362- | Series [bool ]
2363- | Series [int ]
2364- | Series [float ]
2365- ),
2343+ def __rfloordiv__ (
2344+ self : Series [Never ], other : ScalarArrayIndexSeriesReal
23662345 ) -> Series : ...
23672346 @overload
23682347 def __rfloordiv__ (self , other : np_ndarray_complex | np_ndarray_dt ) -> Never : ...
@@ -2422,29 +2401,16 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
24222401 @overload
24232402 def __rfloordiv__ (
24242403 self : Series [int ] | Series [float ],
2425- other : timedelta | np_ndarray_td | TimedeltaIndex | Series [ Timedelta ] ,
2404+ other : timedelta | np . timedelta64 | ArrayIndexSeriesTimedeltaNoSeq ,
24262405 ) -> Series [Timedelta ]: ...
24272406 @overload
24282407 def __rfloordiv__ (
2429- self : Series [Timedelta ],
2430- other : np_ndarray_td | TimedeltaIndex | Series [Timedelta ],
2408+ self : Series [Timedelta ], other : ArrayIndexSeriesTimedeltaNoSeq
24312409 ) -> Series [int ]: ...
24322410 @overload
24332411 def rfloordiv (
24342412 self : Series [Never ],
2435- other : (
2436- float
2437- | Sequence [float ]
2438- | np_ndarray_bool
2439- | np_ndarray_anyint
2440- | np_ndarray_float
2441- | Index [bool ]
2442- | Index [int ]
2443- | Index [float ]
2444- | Series [bool ]
2445- | Series [int ]
2446- | Series [float ]
2447- ),
2413+ other : ScalarArrayIndexSeriesReal ,
24482414 level : Level | None = ...,
24492415 fill_value : float | None = None ,
24502416 axis : AxisIndex | None = 0 ,
@@ -2524,7 +2490,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
25242490 @overload
25252491 def rfloordiv (
25262492 self : Series [Timedelta ],
2527- other : np_ndarray_td | TimedeltaIndex | Series [ Timedelta ] ,
2493+ other : ArrayIndexSeriesTimedeltaNoSeq ,
25282494 level : Level | None = ...,
25292495 fill_value : float | None = None ,
25302496 axis : AxisIndex = ...,
@@ -3641,19 +3607,17 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
36413607 def __truediv__ (self , other : np_ndarray_dt ) -> Never : ...
36423608 @overload
36433609 def __truediv__ ( # type: ignore[overload-overlap]
3644- self : Series [Never ], other : _OtherTrueDiv
3610+ self : Series [Never ], other : ScalarArrayIndexSeriesComplex
36453611 ) -> Series : ...
36463612 @overload
3647- def __truediv__ (
3648- self : Series [Never ], other : np_ndarray_td | TimedeltaIndex
3649- ) -> Never : ...
3613+ def __truediv__ (self : Series [Never ], other : ArrayIndexTimedeltaNoSeq ) -> Never : ...
36503614 @overload
36513615 def __truediv__ (self : Series [T_COMPLEX ], other : np_ndarray_td ) -> Never : ...
36523616 @overload
36533617 def __truediv__ (self : Series [bool ], other : np_ndarray_bool ) -> Never : ...
36543618 @overload
36553619 def __truediv__ (
3656- self : Series [T_COMPLEX ], other : Index [Never ] | Series [Never ]
3620+ self : SeriesComplex | Series [Timedelta ], other : Index [Never ] | Series [Never ]
36573621 ) -> Series : ...
36583622 @overload
36593623 def __truediv__ (
@@ -3723,7 +3687,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
37233687 ) -> Series [T_COMPLEX ]: ...
37243688 @overload
37253689 def __truediv__ (
3726- self : Series [ T_COMPLEX ] ,
3690+ self : SeriesComplex ,
37273691 other : (
37283692 Just [complex ]
37293693 | Sequence [Just [complex ]]
@@ -3750,30 +3714,29 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
37503714 ) -> Series [Timedelta ]: ...
37513715 @overload
37523716 def __truediv__ (
3753- self : Series [Timedelta ],
3754- other : np_ndarray_td | TimedeltaIndex | Series [Timedelta ],
3717+ self : Series [Timedelta ], other : ArrayIndexSeriesTimedeltaNoSeq
37553718 ) -> Series [float ]: ...
37563719 @overload
37573720 def __truediv__ (self : Series [_str ], other : Path ) -> Series : ...
37583721 @overload
3759- def truediv (
3722+ def truediv ( # type: ignore[overload-overlap]
37603723 self : Series [Never ],
3761- other : _OtherTrueDiv ,
3724+ other : ScalarArrayIndexSeriesComplex ,
37623725 level : Level | None = None ,
37633726 fill_value : float | None = None ,
37643727 axis : AxisIndex = 0 ,
37653728 ) -> Series : ...
37663729 @overload
37673730 def truediv (
37683731 self : Series [Never ],
3769- other : np_ndarray_td | TimedeltaIndex ,
3732+ other : ArrayIndexTimedeltaNoSeq ,
37703733 level : Level | None = None ,
37713734 fill_value : float | None = None ,
37723735 axis : AxisIndex = 0 ,
37733736 ) -> Never : ...
37743737 @overload
37753738 def truediv (
3776- self : Series [ bool ] | Series [int ] | Series [ float ] | Series [ complex ],
3739+ self : SeriesComplex | Series [Timedelta ],
37773740 other : Index [Never ] | Series [Never ],
37783741 level : Level | None = None ,
37793742 fill_value : float | None = None ,
@@ -3863,7 +3826,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
38633826 ) -> Series [T_COMPLEX ]: ...
38643827 @overload
38653828 def truediv (
3866- self : Series [ T_COMPLEX ] ,
3829+ self : SeriesComplex ,
38673830 other : (
38683831 Just [complex ]
38693832 | Sequence [Just [complex ]]
@@ -3897,7 +3860,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
38973860 @overload
38983861 def truediv (
38993862 self : Series [Timedelta ],
3900- other : np_ndarray_td | TimedeltaIndex | Series [ Timedelta ] ,
3863+ other : ArrayIndexSeriesTimedeltaNoSeq ,
39013864 level : Level | None = None ,
39023865 fill_value : float | None = None ,
39033866 axis : AxisIndex = 0 ,
@@ -3916,16 +3879,18 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
39163879 @overload
39173880 def __rtruediv__ (
39183881 self : Series [Never ],
3919- other : timedelta | Sequence [timedelta ] | np_ndarray_td | TimedeltaIndex ,
3920- ) -> Never : ...
3921- @overload
3922- def __rtruediv__ (self : Series [Never ], other : _OtherRTrueDiv ) -> Series : ...
3882+ other : ScalarArrayIndexSeriesComplex | ScalarArrayIndexSeriesTimedelta ,
3883+ ) -> Series : ...
39233884 @overload
39243885 def __rtruediv__ (
39253886 self : Series [bool ] | Series [int ] | Series [float ] | Series [complex ],
39263887 other : Index [Never ] | Series [Never ],
39273888 ) -> Series : ...
39283889 @overload
3890+ def __rtruediv__ (
3891+ self : Series [int ] | Series [float ], other : Sequence [timedelta | np .timedelta64 ]
3892+ ) -> Series : ...
3893+ @overload
39293894 def __rtruediv__ (
39303895 self : Supports_ProtoRTrueDiv [_T_contra , S2 ],
39313896 other : _T_contra | Sequence [_T_contra ],
@@ -3987,7 +3952,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
39873952 ) -> Series [T_COMPLEX ]: ...
39883953 @overload
39893954 def __rtruediv__ (
3990- self : Series [ T_COMPLEX ] ,
3955+ self : SeriesComplex ,
39913956 other : (
39923957 Just [complex ]
39933958 | Sequence [Just [complex ]]
@@ -3998,8 +3963,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
39983963 ) -> Series [complex ]: ...
39993964 @overload
40003965 def __rtruediv__ (
4001- self : Series [Timedelta ],
4002- other : np_ndarray_td | TimedeltaIndex | Series [Timedelta ],
3966+ self : Series [Timedelta ], other : ArrayIndexSeriesTimedeltaNoSeq
40033967 ) -> Series [float ]: ...
40043968 @overload
40053969 def __rtruediv__ (
@@ -4017,20 +3981,12 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
40173981 @overload
40183982 def rtruediv (
40193983 self : Series [Never ],
4020- other : _OtherRTrueDiv ,
3984+ other : ScalarArrayIndexSeriesComplex | ScalarArrayIndexSeriesTimedelta ,
40213985 level : Level | None = None ,
40223986 fill_value : float | None = None ,
40233987 axis : AxisIndex = 0 ,
40243988 ) -> Series : ...
40253989 @overload
4026- def rtruediv (
4027- self : Series [Never ],
4028- other : timedelta | Sequence [timedelta ] | np_ndarray_td | TimedeltaIndex ,
4029- level : Level | None = None ,
4030- fill_value : float | None = None ,
4031- axis : AxisIndex = 0 ,
4032- ) -> Never : ...
4033- @overload
40343990 def rtruediv (
40353991 self : Series [bool ] | Series [int ] | Series [float ] | Series [complex ],
40363992 other : Index [Never ] | Series [Never ],
@@ -4122,7 +4078,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
41224078 ) -> Series [T_COMPLEX ]: ...
41234079 @overload
41244080 def rtruediv (
4125- self : Series [ T_COMPLEX ] ,
4081+ self : SeriesComplex ,
41264082 other : (
41274083 Just [complex ]
41284084 | Sequence [Just [complex ]]
@@ -4137,7 +4093,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
41374093 @overload
41384094 def rtruediv (
41394095 self : Series [Timedelta ],
4140- other : np_ndarray_td | TimedeltaIndex | Series [ Timedelta ] ,
4096+ other : ArrayIndexSeriesTimedeltaNoSeq ,
41414097 level : Level | None = None ,
41424098 fill_value : float | None = None ,
41434099 axis : AxisIndex = 0 ,
0 commit comments