@@ -13,19 +13,14 @@ from typing import (
1313)
1414
1515import numpy as np
16- import pandas as pd
17- from pandas import (
18- DatetimeIndex ,
19- Index ,
20- PeriodIndex ,
21- Series ,
22- TimedeltaIndex ,
23- )
16+ from pandas .core .indexes .base import Index
17+ from pandas .core .indexes .datetimes import DatetimeIndex
18+ from pandas .core .indexes .period import PeriodIndex
19+ from pandas .core .indexes .timedeltas import TimedeltaIndex
20+ from pandas .core .series import Series
2421from typing_extensions import Self
2522
26- from pandas ._libs .tslibs import (
27- NaTType ,
28- )
23+ from pandas ._libs .tslibs import NaTType
2924from pandas ._libs .tslibs .period import Period
3025from pandas ._libs .tslibs .timestamps import Timestamp
3126from pandas ._typing import (
@@ -131,7 +126,7 @@ class Timedelta(timedelta):
131126 def to_timedelta64 (self ) -> np .timedelta64 : ...
132127 @property
133128 def asm8 (self ) -> np .timedelta64 : ...
134- # TODO: round/floor/ceil could return NaT?
129+ # TODO: pandas-dev/pandas-stubs#1432 round/floor/ceil could return NaT?
135130 def round (self , freq : Frequency ) -> Self : ...
136131 def floor (self , freq : Frequency ) -> Self : ...
137132 def ceil (self , freq : Frequency ) -> Self : ...
@@ -174,17 +169,17 @@ class Timedelta(timedelta):
174169 ) -> np_ndarray [ShapeT , np .datetime64 ]: ...
175170 # Override due to more types supported than timedelta
176171 @overload # type: ignore[override]
177- def __sub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Self : ...
172+ def __sub__ (self , other : timedelta | np .timedelta64 | Self ) -> Self : ...
178173 @overload
179174 def __sub__ (self , other : NaTType ) -> NaTType : ...
180175 @overload
181176 def __sub__ (
182177 self , other : np_ndarray [ShapeT , np .timedelta64 ]
183178 ) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
184179 @overload
185- def __sub__ (self , other : pd . TimedeltaIndex ) -> TimedeltaIndex : ...
180+ def __sub__ (self , other : TimedeltaIndex ) -> TimedeltaIndex : ...
186181 @overload
187- def __rsub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Self : ...
182+ def __rsub__ (self , other : timedelta | np .timedelta64 | Self ) -> Self : ...
188183 @overload
189184 def __rsub__ (self , other : datetime | Timestamp | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
190185 @overload
@@ -204,7 +199,7 @@ class Timedelta(timedelta):
204199 self , other : np_ndarray [ShapeT , np .timedelta64 ]
205200 ) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
206201 @overload
207- def __rsub__ (self , other : pd . TimedeltaIndex ) -> pd . TimedeltaIndex : ...
202+ def __rsub__ (self , other : TimedeltaIndex ) -> TimedeltaIndex : ...
208203 def __neg__ (self ) -> Self : ...
209204 def __pos__ (self ) -> Self : ...
210205 def __abs__ (self ) -> Self : ...
@@ -224,7 +219,7 @@ class Timedelta(timedelta):
224219 # Override due to more types supported than timedelta
225220 # error: Signature of "__floordiv__" incompatible with supertype "timedelta"
226221 @overload # type: ignore[override]
227- def __floordiv__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> int : ...
222+ def __floordiv__ (self , other : timedelta | np .timedelta64 | Self ) -> int : ...
228223 @overload
229224 def __floordiv__ (self , other : float ) -> Self : ...
230225 @overload
@@ -273,9 +268,9 @@ class Timedelta(timedelta):
273268 def __rtruediv__ (self , other : timedelta | Timedelta | NaTType ) -> float : ...
274269 # Override due to more types supported than timedelta
275270 @overload
276- def __eq__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
271+ def __eq__ (self , other : timedelta | np .timedelta64 | Self ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
277272 @overload
278- def __eq__ (self , other : Series [pd . Timedelta ]) -> Series [bool ]: ... # type: ignore[overload-overlap]
273+ def __eq__ (self , other : Series [Timedelta ]) -> Series [bool ]: ... # type: ignore[overload-overlap]
279274 @overload
280275 def __eq__ (self , other : Index ) -> np_1darray [np .bool ]: ... # type: ignore[overload-overlap]
281276 @overload
@@ -286,9 +281,9 @@ class Timedelta(timedelta):
286281 def __eq__ (self , other : object ) -> Literal [False ]: ...
287282 # Override due to more types supported than timedelta
288283 @overload
289- def __ne__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
284+ def __ne__ (self , other : timedelta | np .timedelta64 | Self ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
290285 @overload
291- def __ne__ (self , other : Series [pd . Timedelta ]) -> Series [bool ]: ... # type: ignore[overload-overlap]
286+ def __ne__ (self , other : Series [Timedelta ]) -> Series [bool ]: ... # type: ignore[overload-overlap]
292287 @overload
293288 def __ne__ (self , other : Index ) -> np_1darray [np .bool ]: ... # type: ignore[overload-overlap]
294289 @overload
@@ -315,52 +310,50 @@ class Timedelta(timedelta):
315310 self , other : Series [int ] | Series [float ] | Series [Timedelta ]
316311 ) -> Series [Timedelta ]: ...
317312 def __divmod__ (self , other : timedelta ) -> tuple [int , Timedelta ]: ...
318- # Mypy complains Forward operator "<inequality op>" is not callable, so ignore misc
319- # for le, lt ge and gt
320313 # Override due to more types supported than timedelta
321314 @overload # type: ignore[override]
322- def __le__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
315+ def __le__ (self , other : timedelta | np .timedelta64 | Self ) -> bool : ...
323316 @overload
324317 def __le__ (self , other : TimedeltaIndex ) -> np_1darray [np .bool ]: ...
325318 @overload
326319 def __le__ (
327320 self , other : np_ndarray [ShapeT , np .timedelta64 ]
328321 ) -> np_ndarray [ShapeT , np .bool_ ]: ...
329322 @overload
330- def __le__ (self , other : Series [pd . Timedelta ]) -> Series [bool ]: ...
323+ def __le__ (self , other : Series [Timedelta ]) -> Series [bool ]: ...
331324 # Override due to more types supported than timedelta
332325 @overload # type: ignore[override]
333- def __lt__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
326+ def __lt__ (self , other : timedelta | np .timedelta64 | Self ) -> bool : ...
334327 @overload
335328 def __lt__ (self , other : TimedeltaIndex ) -> np_1darray [np .bool ]: ...
336329 @overload
337330 def __lt__ (
338331 self , other : np_ndarray [ShapeT , np .timedelta64 ]
339332 ) -> np_ndarray [ShapeT , np .bool_ ]: ...
340333 @overload
341- def __lt__ (self , other : Series [pd . Timedelta ]) -> Series [bool ]: ...
334+ def __lt__ (self , other : Series [Timedelta ]) -> Series [bool ]: ...
342335 # Override due to more types supported than timedelta
343336 @overload # type: ignore[override]
344- def __ge__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
337+ def __ge__ (self , other : timedelta | np .timedelta64 | Self ) -> bool : ...
345338 @overload
346339 def __ge__ (self , other : TimedeltaIndex ) -> np_1darray [np .bool ]: ...
347340 @overload
348341 def __ge__ (
349342 self , other : np_ndarray [ShapeT , np .timedelta64 ]
350343 ) -> np_ndarray [ShapeT , np .bool_ ]: ...
351344 @overload
352- def __ge__ (self , other : Series [pd . Timedelta ]) -> Series [bool ]: ...
345+ def __ge__ (self , other : Series [Timedelta ]) -> Series [bool ]: ...
353346 # Override due to more types supported than timedelta
354347 @overload # type: ignore[override]
355- def __gt__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
348+ def __gt__ (self , other : timedelta | np .timedelta64 | Self ) -> bool : ...
356349 @overload
357350 def __gt__ (self , other : TimedeltaIndex ) -> np_1darray [np .bool ]: ...
358351 @overload
359352 def __gt__ (
360353 self , other : np_ndarray [ShapeT , np .timedelta64 ]
361354 ) -> np_ndarray [ShapeT , np .bool_ ]: ...
362355 @overload
363- def __gt__ (self , other : Series [pd . Timedelta ]) -> Series [bool ]: ...
356+ def __gt__ (self , other : Series [Timedelta ]) -> Series [bool ]: ...
364357 def __hash__ (self ) -> int : ...
365358 def isoformat (self ) -> str : ...
366359 def to_numpy (self ) -> np .timedelta64 : ...
0 commit comments