@@ -21,8 +21,11 @@ from numpy import typing as npt
2121from pandas .core .arraylike import OpsMixin
2222from pandas .core .arrays import ExtensionArray
2323from pandas .core .arrays .categorical import Categorical
24+ from pandas .core .arrays .integer import IntegerArray
25+ from pandas .core .arrays .timedeltas import TimedeltaArray
2426from pandas .core .indexes .accessors import ArrayDescriptor
2527from pandas .core .indexes .base import Index
28+ from pandas .core .indexes .timedeltas import TimedeltaIndex
2629from pandas .core .series import Series
2730from typing_extensions import Self
2831
@@ -45,6 +48,7 @@ from pandas._typing import (
4548 np_ndarray_bool ,
4649 np_ndarray_complex ,
4750 np_ndarray_float ,
51+ np_ndarray_td ,
4852)
4953from pandas .util ._decorators import cache_readonly
5054
@@ -169,7 +173,84 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
169173 ) -> np .intp : ...
170174 def drop_duplicates (self , * , keep : DropKeep = ...) -> Self : ...
171175
172- NumListLike : TypeAlias = (
176+ ScalarArrayIndexJustInt : TypeAlias = (
177+ Just [int ]
178+ | np .integer
179+ | Sequence [Just [int ] | np .integer ]
180+ | np_ndarray_anyint
181+ | IntegerArray
182+ | Index [int ]
183+ )
184+ ScalarArrayIndexSeriesJustInt : TypeAlias = ScalarArrayIndexJustInt | Series [int ]
185+ ScalarArrayIndexJustFloat : TypeAlias = (
186+ Just [float ]
187+ | np .floating
188+ | Sequence [Just [float ] | np .floating ]
189+ | np_ndarray_float
190+ # | FloatingArray # TODO: after pandas-dev/pandas-stubs#1469
191+ | Index [float ]
192+ )
193+ ScalarArrayIndexSeriesJustFloat : TypeAlias = ScalarArrayIndexJustFloat | Series [float ]
194+ ScalarArrayIndexJustComplex : TypeAlias = (
195+ Just [complex ]
196+ | np .complexfloating
197+ | Sequence [Just [complex ] | np .complexfloating ]
198+ | np_ndarray_complex
199+ | Index [complex ]
200+ )
201+ ScalarArrayIndexSeriesJustComplex : TypeAlias = (
202+ ScalarArrayIndexJustComplex | Series [complex ]
203+ )
204+
205+ ScalarArrayIndexIntNoBool : TypeAlias = (
206+ Just [int ]
207+ | np .integer
208+ | Sequence [int | np .integer ]
209+ | np_ndarray_anyint
210+ | IntegerArray
211+ | Index [int ]
212+ )
213+ ScalarArrayIndexSeriesIntNoBool : TypeAlias = ScalarArrayIndexIntNoBool | Series [int ]
214+
215+ NumpyRealScalar : TypeAlias = np .bool | np .integer | np .floating
216+ IndexReal : TypeAlias = Index [bool ] | Index [int ] | Index [float ]
217+ ScalarArrayIndexReal : TypeAlias = (
218+ float
219+ | Sequence [float | NumpyRealScalar ]
220+ | NumpyRealScalar
221+ | np .typing .NDArray [NumpyRealScalar ]
222+ | ExtensionArray
223+ | IndexReal
224+ )
225+ SeriesReal : TypeAlias = Series [bool ] | Series [int ] | Series [float ]
226+ ScalarArrayIndexSeriesReal : TypeAlias = ScalarArrayIndexReal | SeriesReal
227+
228+ NumpyComplexScalar : TypeAlias = NumpyRealScalar | np .complexfloating
229+ IndexComplex : TypeAlias = IndexReal | Index [complex ]
230+ ScalarArrayIndexComplex : TypeAlias = (
231+ complex
232+ | Sequence [complex | NumpyComplexScalar ]
233+ | NumpyComplexScalar
234+ | np .typing .NDArray [NumpyComplexScalar ]
235+ | ExtensionArray
236+ | IndexComplex
237+ )
238+ SeriesComplex : TypeAlias = SeriesReal | Series [complex ]
239+ ScalarArrayIndexSeriesComplex : TypeAlias = ScalarArrayIndexComplex | SeriesComplex
240+
241+ ArrayIndexTimedeltaNoSeq : TypeAlias = np_ndarray_td | TimedeltaArray | TimedeltaIndex
242+ ScalarArrayIndexTimedelta : TypeAlias = (
243+ timedelta
244+ | np .timedelta64
245+ | Sequence [timedelta | np .timedelta64 ]
246+ | ArrayIndexTimedeltaNoSeq
247+ )
248+ ArrayIndexSeriesTimedeltaNoSeq : TypeAlias = ArrayIndexTimedeltaNoSeq | Series [Timedelta ]
249+ ScalarArrayIndexSeriesTimedelta : TypeAlias = (
250+ ScalarArrayIndexTimedelta | Series [Timedelta ]
251+ )
252+
253+ NumListLike : TypeAlias = ( # TODO: pandas-dev/pandas-stubs#1474 deprecated, do not use
173254 ExtensionArray
174255 | np_ndarray_bool
175256 | np_ndarray_anyint
@@ -281,7 +362,7 @@ class ElementOpsMixin(Generic[S2]):
281362 ) -> ElementOpsMixin [complex ]: ...
282363 @overload
283364 def _proto_truediv (
284- self : ElementOpsMixin [Timedelta ], other : timedelta | Timedelta | np .timedelta64
365+ self : ElementOpsMixin [Timedelta ], other : timedelta | np .timedelta64 | Timedelta
285366 ) -> ElementOpsMixin [float ]: ...
286367 @overload
287368 def _proto_rtruediv (
@@ -297,8 +378,32 @@ class ElementOpsMixin(Generic[S2]):
297378 ) -> ElementOpsMixin [complex ]: ...
298379 @overload
299380 def _proto_rtruediv (
300- self : ElementOpsMixin [Timedelta ], other : timedelta | Timedelta | np .timedelta64
381+ self : ElementOpsMixin [Timedelta ], other : timedelta | np .timedelta64 | Timedelta
382+ ) -> ElementOpsMixin [float ]: ...
383+ @overload
384+ def _proto_floordiv (
385+ self : ElementOpsMixin [int ], other : int | np .integer
386+ ) -> ElementOpsMixin [int ]: ...
387+ @overload
388+ def _proto_floordiv (
389+ self : ElementOpsMixin [float ], other : float | np .floating
301390 ) -> ElementOpsMixin [float ]: ...
391+ @overload
392+ def _proto_floordiv (
393+ self : ElementOpsMixin [Timedelta ], other : timedelta | np .timedelta64 | Timedelta
394+ ) -> ElementOpsMixin [int ]: ...
395+ @overload
396+ def _proto_rfloordiv (
397+ self : ElementOpsMixin [int ], other : int | np .integer
398+ ) -> ElementOpsMixin [int ]: ...
399+ @overload
400+ def _proto_rfloordiv (
401+ self : ElementOpsMixin [float ], other : float | np .floating
402+ ) -> ElementOpsMixin [float ]: ...
403+ @overload
404+ def _proto_rfloordiv (
405+ self : ElementOpsMixin [Timedelta ], other : timedelta | np .timedelta64 | Timedelta
406+ ) -> ElementOpsMixin [int ]: ...
302407
303408@type_check_only
304409class Supports_ProtoAdd (Protocol [_T_contra , S2 ]):
@@ -323,3 +428,11 @@ class Supports_ProtoTrueDiv(Protocol[_T_contra, S2]):
323428@type_check_only
324429class Supports_ProtoRTrueDiv (Protocol [_T_contra , S2 ]):
325430 def _proto_rtruediv (self , other : _T_contra , / ) -> ElementOpsMixin [S2 ]: ...
431+
432+ @type_check_only
433+ class Supports_ProtoFloorDiv (Protocol [_T_contra , S2 ]):
434+ def _proto_floordiv (self , other : _T_contra , / ) -> ElementOpsMixin [S2 ]: ...
435+
436+ @type_check_only
437+ class Supports_ProtoRFloorDiv (Protocol [_T_contra , S2 ]):
438+ def _proto_rfloordiv (self , other : _T_contra , / ) -> ElementOpsMixin [S2 ]: ...
0 commit comments