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,7 +173,7 @@ 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
178
def __sub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Timedelta : ...
176
179
@overload
@@ -186,7 +189,7 @@ class Timedelta(timedelta):
186
189
@overload
187
190
def __rsub__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> Timedelta : ...
188
191
@overload
189
- def __rsub__ (self , other : dt . datetime | Timestamp | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
192
+ def __rsub__ (self , other : datetime | Timestamp | np .datetime64 ) -> Timestamp : ... # type: ignore[misc]
190
193
@overload
191
194
def __rsub__ (self , other : NaTType ) -> NaTType : ...
192
195
@overload
@@ -208,41 +211,28 @@ class Timedelta(timedelta):
208
211
def __neg__ (self ) -> Timedelta : ...
209
212
def __pos__ (self ) -> Timedelta : ...
210
213
def __abs__ (self ) -> Timedelta : ...
211
- # Override due to more types supported than dt. timedelta
214
+ # Override due to more types supported than timedelta
212
215
@overload # type: ignore[override]
213
216
def __mul__ (self , other : float ) -> Timedelta : ...
214
217
@overload
215
218
def __mul__ (
216
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
219
+ self , other : np_ndarray [ShapeT , np .bool_ | np . integer | np .floating ]
217
220
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
218
221
@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
222
def __rmul__ (self , other : float ) -> Timedelta : ...
226
223
@overload
227
224
def __rmul__ (
228
- self , other : np_ndarray [ShapeT , np .floating ] | np_ndarray [ ShapeT , np .integer ]
225
+ self , other : np_ndarray [ShapeT , np .bool_ | np .integer | np . floating ]
229
226
) -> 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
227
+ # Override due to more types supported than timedelta
238
228
# error: Signature of "__floordiv__" incompatible with supertype "timedelta"
239
229
@overload # type: ignore[override]
240
230
def __floordiv__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> int : ...
241
231
@overload
242
232
def __floordiv__ (self , other : float ) -> Timedelta : ...
243
233
@overload
244
234
def __floordiv__ (
245
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
235
+ self , other : np_ndarray [ShapeT , np .integer | np .floating ]
246
236
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
247
237
@overload
248
238
def __floordiv__ (
@@ -266,14 +256,14 @@ class Timedelta(timedelta):
266
256
def __rfloordiv__ (
267
257
self , other : np_ndarray [ShapeT , np .timedelta64 ]
268
258
) -> np_ndarray [ShapeT , np .int_ ]: ...
269
- # Override due to more types supported than dt. timedelta
259
+ # Override due to more types supported than timedelta
270
260
@overload # type: ignore[override]
271
261
def __truediv__ (self , other : timedelta | Timedelta | NaTType ) -> float : ...
272
262
@overload
273
263
def __truediv__ (self , other : float ) -> Timedelta : ...
274
264
@overload
275
265
def __truediv__ (
276
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
266
+ self , other : np_ndarray [ShapeT , np .integer | np .floating ]
277
267
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
278
268
@overload
279
269
def __truediv__ (self , other : Series [Timedelta ]) -> Series [float ]: ...
@@ -284,7 +274,7 @@ class Timedelta(timedelta):
284
274
@overload
285
275
def __truediv__ (self , other : Index [int ] | Index [float ]) -> TimedeltaIndex : ...
286
276
def __rtruediv__ (self , other : timedelta | Timedelta | NaTType ) -> float : ...
287
- # Override due to more types supported than dt. timedelta
277
+ # Override due to more types supported than timedelta
288
278
@overload
289
279
def __eq__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
290
280
@overload
@@ -297,7 +287,7 @@ class Timedelta(timedelta):
297
287
) -> np_ndarray [ShapeT , np .bool_ ]: ...
298
288
@overload
299
289
def __eq__ (self , other : object ) -> Literal [False ]: ...
300
- # Override due to more types supported than dt. timedelta
290
+ # Override due to more types supported than timedelta
301
291
@overload
302
292
def __ne__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
303
293
@overload
@@ -310,7 +300,7 @@ class Timedelta(timedelta):
310
300
) -> np_ndarray [ShapeT , np .bool_ ]: ...
311
301
@overload
312
302
def __ne__ (self , other : object ) -> Literal [True ]: ...
313
- # Override due to more types supported than dt. timedelta
303
+ # Override due to more types supported than timedelta
314
304
@overload # type: ignore[override]
315
305
def __mod__ (self , other : timedelta ) -> Timedelta : ...
316
306
@overload
@@ -321,7 +311,7 @@ class Timedelta(timedelta):
321
311
def __mod__ (self , other : Index [int ] | Index [float ]) -> TimedeltaIndex : ...
322
312
@overload
323
313
def __mod__ (
324
- self , other : np_ndarray [ShapeT , np .integer ] | np_ndarray [ ShapeT , np .floating ]
314
+ self , other : np_ndarray [ShapeT , np .integer | np .floating ]
325
315
) -> np_ndarray [ShapeT , np .timedelta64 ]: ...
326
316
@overload
327
317
def __mod__ (
@@ -330,7 +320,7 @@ class Timedelta(timedelta):
330
320
def __divmod__ (self , other : timedelta ) -> tuple [int , Timedelta ]: ...
331
321
# Mypy complains Forward operator "<inequality op>" is not callable, so ignore misc
332
322
# for le, lt ge and gt
333
- # Override due to more types supported than dt. timedelta
323
+ # Override due to more types supported than timedelta
334
324
@overload # type: ignore[override]
335
325
def __le__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
336
326
@overload
@@ -341,7 +331,7 @@ class Timedelta(timedelta):
341
331
) -> np_ndarray [ShapeT , np .bool_ ]: ...
342
332
@overload
343
333
def __le__ (self , other : Series [pd .Timedelta ]) -> Series [bool ]: ...
344
- # Override due to more types supported than dt. timedelta
334
+ # Override due to more types supported than timedelta
345
335
@overload # type: ignore[override]
346
336
def __lt__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
347
337
@overload
@@ -352,7 +342,7 @@ class Timedelta(timedelta):
352
342
) -> np_ndarray [ShapeT , np .bool_ ]: ...
353
343
@overload
354
344
def __lt__ (self , other : Series [pd .Timedelta ]) -> Series [bool ]: ...
355
- # Override due to more types supported than dt. timedelta
345
+ # Override due to more types supported than timedelta
356
346
@overload # type: ignore[override]
357
347
def __ge__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
358
348
@overload
@@ -363,7 +353,7 @@ class Timedelta(timedelta):
363
353
) -> np_ndarray [ShapeT , np .bool_ ]: ...
364
354
@overload
365
355
def __ge__ (self , other : Series [pd .Timedelta ]) -> Series [bool ]: ...
366
- # Override due to more types supported than dt. timedelta
356
+ # Override due to more types supported than timedelta
367
357
@overload # type: ignore[override]
368
358
def __gt__ (self , other : timedelta | Timedelta | np .timedelta64 ) -> bool : ... # type: ignore[misc]
369
359
@overload
0 commit comments