1
1
# pyright: strict
2
- import datetime as dt
3
- from datetime import timedelta
2
+ from datetime import (
3
+ date ,
4
+ datetime ,
5
+ timedelta ,
6
+ )
4
7
from typing import (
5
8
ClassVar ,
6
9
Literal ,
@@ -135,17 +138,17 @@ class Timedelta(timedelta):
135
138
def ceil (self , freq : str | BaseOffset ) -> Self : ...
136
139
@property
137
140
def resolution_string (self ) -> str : ...
138
- # Override due to more types supported than dt. timedelta
141
+ # Override due to more types supported than timedelta
139
142
@overload # type: ignore[override]
140
- def __add__ (self , other : dt . datetime | np .datetime64 ) -> Timestamp : ...
143
+ def __add__ (self , other : datetime | np .datetime64 ) -> Timestamp : ...
141
144
@overload
142
145
def __add__ (self , other : timedelta | np .timedelta64 ) -> Self : ...
143
146
@overload
144
147
def __add__ (self , other : NaTType ) -> NaTType : ...
145
148
@overload
146
149
def __add__ (self , other : Period ) -> Period : ...
147
150
@overload
148
- def __add__ (self , other : dt . date ) -> dt . date : ...
151
+ def __add__ (self , other : date ) -> date : ...
149
152
@overload
150
153
def __add__ (
151
154
self , other : np_ndarray [ShapeT , np .timedelta64 ]
@@ -155,13 +158,13 @@ class Timedelta(timedelta):
155
158
self , other : np_ndarray [ShapeT , np .datetime64 ]
156
159
) -> np_ndarray [ShapeT , np .datetime64 ]: ...
157
160
@overload
158
- def __radd__ (self , other : dt . datetime | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
161
+ def __radd__ (self , other : datetime | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
159
162
@overload
160
163
def __radd__ (self , other : timedelta | np .timedelta64 ) -> Self : ...
161
164
@overload
162
165
def __radd__ (self , other : NaTType ) -> NaTType : ...
163
166
@overload
164
- def __radd__ (self , other : dt . date ) -> dt . date : ...
167
+ def __radd__ (self , other : date ) -> date : ...
165
168
@overload
166
169
def __radd__ (
167
170
self , other : np_ndarray [ShapeT , np .timedelta64 ]
@@ -170,9 +173,9 @@ class Timedelta(timedelta):
170
173
def __radd__ (
171
174
self , other : np_ndarray [ShapeT , np .datetime64 ]
172
175
) -> np_ndarray [ShapeT , np .datetime64 ]: ...
173
- # Override due to more types supported than dt. timedelta
176
+ # Override due to more types supported than timedelta
174
177
@overload # type: ignore[override]
175
- def __sub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Timedelta : ...
178
+ def __sub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Self : ...
176
179
@overload
177
180
def __sub__ (self , other : NaTType ) -> NaTType : ...
178
181
@overload
@@ -182,11 +185,9 @@ class Timedelta(timedelta):
182
185
@overload
183
186
def __sub__ (self , other : pd .TimedeltaIndex ) -> TimedeltaIndex : ...
184
187
@overload
185
- def __sub__ (self , other : Series [pd .Timedelta ]) -> Series [pd .Timedelta ]: ...
186
- @overload
187
- def __rsub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Timedelta : ...
188
+ def __rsub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Self : ...
188
189
@overload
189
- def __rsub__ (self , other : dt . datetime | Timestamp | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
190
+ def __rsub__ (self , other : datetime | Timestamp | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
190
191
@overload
191
192
def __rsub__ (self , other : NaTType ) -> NaTType : ...
192
193
@overload
@@ -205,44 +206,31 @@ class Timedelta(timedelta):
205
206
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
206
207
@overload
207
208
def __rsub__ (self , other : pd .TimedeltaIndex ) -> pd .TimedeltaIndex : ...
208
- def __neg__ (self ) -> Timedelta : ...
209
- def __pos__ (self ) -> Timedelta : ...
210
- def __abs__ (self ) -> Timedelta : ...
211
- # Override due to more types supported than dt. timedelta
209
+ def __neg__ (self ) -> Self : ...
210
+ def __pos__ (self ) -> Self : ...
211
+ def __abs__ (self ) -> Self : ...
212
+ # Override due to more types supported than timedelta
212
213
@overload # type: ignore[override]
213
- def __mul__ (self , other : float ) -> Timedelta : ...
214
+ def __mul__ (self , other : float ) -> Self : ...
214
215
@overload
215
216
def __mul__ (
216
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
217
+ self , other : np_ndarray [ShapeT , np .bool_ | np . integer | np .floating ]
217
218
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
218
219
@overload
219
- def __mul__ (self , other : Series [int ]) -> Series [Timedelta ]: ...
220
- @overload
221
- def __mul__ (self , other : Series [float ]) -> Series [Timedelta ]: ...
222
- @overload
223
- def __mul__ (self , other : Index [int ] | Index [float ]) -> TimedeltaIndex : ...
224
- @overload
225
- def __rmul__ (self , other : float ) -> Timedelta : ...
220
+ def __rmul__ (self , other : float ) -> Self : ...
226
221
@overload
227
222
def __rmul__ (
228
- self , other : np_ndarray [ShapeT , np .floating ] | np_ndarray [ ShapeT , np .integer ]
223
+ self , other : np_ndarray [ShapeT , np .bool_ | np .integer | np . floating ]
229
224
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
230
- @overload
231
- def __rmul__ (self , other : Series [int ]) -> Series [Timedelta ]: ...
232
- @overload
233
- def __rmul__ (self , other : Series [float ]) -> Series [Timedelta ]: ...
234
- # maybe related to https://github.com/python/mypy/issues/10755
235
- @overload
236
- def __rmul__ (self , other : Index [int ] | Index [float ]) -> TimedeltaIndex : ...
237
- # Override due to more types supported than dt.timedelta
225
+ # Override due to more types supported than timedelta
238
226
# error: Signature of "__floordiv__" incompatible with supertype "timedelta"
239
227
@overload # type: ignore[override]
240
228
def __floordiv__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> int : ...
241
229
@overload
242
- def __floordiv__ (self , other : float ) -> Timedelta : ...
230
+ def __floordiv__ (self , other : float ) -> Self : ...
243
231
@overload
244
232
def __floordiv__ (
245
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
233
+ self , other : np_ndarray [ShapeT , np .integer | np .floating ]
246
234
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
247
235
@overload
248
236
def __floordiv__ (
@@ -266,14 +254,14 @@ class Timedelta(timedelta):
266
254
def __rfloordiv__ (
267
255
self , other : np_ndarray [ShapeT , np .timedelta64 ]
268
256
) -> np_ndarray [ShapeT , np .int_ ]: ...
269
- # Override due to more types supported than dt. timedelta
257
+ # Override due to more types supported than timedelta
270
258
@overload # type: ignore[override]
271
259
def __truediv__ (self , other : timedelta | Timedelta | NaTType ) -> float : ...
272
260
@overload
273
- def __truediv__ (self , other : float ) -> Timedelta : ...
261
+ def __truediv__ (self , other : float ) -> Self : ...
274
262
@overload
275
263
def __truediv__ (
276
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
264
+ self , other : np_ndarray [ShapeT , np .integer | np .floating ]
277
265
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
278
266
@overload
279
267
def __truediv__ (self , other : Series [Timedelta ]) -> Series [float ]: ...
@@ -284,7 +272,7 @@ class Timedelta(timedelta):
284
272
@overload
285
273
def __truediv__ (self , other : Index [int ] | Index [float ]) -> TimedeltaIndex : ...
286
274
def __rtruediv__ (self , other : timedelta | Timedelta | NaTType ) -> float : ...
287
- # Override due to more types supported than dt. timedelta
275
+ # Override due to more types supported than timedelta
288
276
@overload
289
277
def __eq__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
290
278
@overload
@@ -297,7 +285,7 @@ class Timedelta(timedelta):
297
285
) -> np_ndarray [ShapeT , np .bool_ ]: ...
298
286
@overload
299
287
def __eq__ (self , other : object ) -> Literal [False ]: ...
300
- # Override due to more types supported than dt. timedelta
288
+ # Override due to more types supported than timedelta
301
289
@overload
302
290
def __ne__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
303
291
@overload
@@ -310,18 +298,18 @@ class Timedelta(timedelta):
310
298
) -> np_ndarray [ShapeT , np .bool_ ]: ...
311
299
@overload
312
300
def __ne__ (self , other : object ) -> Literal [True ]: ...
313
- # Override due to more types supported than dt. timedelta
301
+ # Override due to more types supported than timedelta
314
302
@overload # type: ignore[override]
315
- def __mod__ (self , other : timedelta ) -> Timedelta : ...
303
+ def __mod__ (self , other : timedelta ) -> Self : ...
316
304
@overload
317
- def __mod__ (self , other : float ) -> Timedelta : ...
305
+ def __mod__ (self , other : float ) -> Self : ...
318
306
@overload
319
307
def __mod__ (self , other : Series [int ] | Series [float ]) -> Series [Timedelta ]: ...
320
308
@overload
321
309
def __mod__ (self , other : Index [int ] | Index [float ]) -> TimedeltaIndex : ...
322
310
@overload
323
311
def __mod__ (
324
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
312
+ self , other : np_ndarray [ShapeT , np .integer | np .floating ]
325
313
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
326
314
@overload
327
315
def __mod__ (
@@ -330,7 +318,7 @@ class Timedelta(timedelta):
330
318
def __divmod__ (self , other : timedelta ) -> tuple [int , Timedelta ]: ...
331
319
# Mypy complains Forward operator "<inequality op>" is not callable, so ignore misc
332
320
# for le, lt ge and gt
333
- # Override due to more types supported than dt. timedelta
321
+ # Override due to more types supported than timedelta
334
322
@overload # type: ignore[override]
335
323
def __le__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
336
324
@overload
@@ -341,7 +329,7 @@ class Timedelta(timedelta):
341
329
) -> np_ndarray [ShapeT , np .bool_ ]: ...
342
330
@overload
343
331
def __le__ (self , other : Series [pd .Timedelta ]) -> Series [bool ]: ...
344
- # Override due to more types supported than dt. timedelta
332
+ # Override due to more types supported than timedelta
345
333
@overload # type: ignore[override]
346
334
def __lt__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
347
335
@overload
@@ -352,7 +340,7 @@ class Timedelta(timedelta):
352
340
) -> np_ndarray [ShapeT , np .bool_ ]: ...
353
341
@overload
354
342
def __lt__ (self , other : Series [pd .Timedelta ]) -> Series [bool ]: ...
355
- # Override due to more types supported than dt. timedelta
343
+ # Override due to more types supported than timedelta
356
344
@overload # type: ignore[override]
357
345
def __ge__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
358
346
@overload
@@ -363,7 +351,7 @@ class Timedelta(timedelta):
363
351
) -> np_ndarray [ShapeT , np .bool_ ]: ...
364
352
@overload
365
353
def __ge__ (self , other : Series [pd .Timedelta ]) -> Series [bool ]: ...
366
- # Override due to more types supported than dt. timedelta
354
+ # Override due to more types supported than timedelta
367
355
@overload # type: ignore[override]
368
356
def __gt__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
369
357
@overload
0 commit comments