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