Skip to content

Commit 3d8c0b6

Browse files
committed
stubtest fixup
1 parent 8863e26 commit 3d8c0b6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pandas/core/indexes/timedeltas.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
if TYPE_CHECKING:
3939
from pandas._libs import NaTType
40+
from pandas._libs.tslibs import (
41+
Day,
42+
Tick,
43+
)
4044
from pandas._typing import (
4145
DtypeObj,
4246
TimeUnit,
@@ -358,22 +362,23 @@ def timedelta_range(
358362
start = Timedelta(start)
359363
end = Timedelta(end)
360364
if abbrev_to_npy_unit(start.unit) > abbrev_to_npy_unit(end.unit):
361-
unit = start.unit
365+
unit = cast("TimeUnit", start.unit)
362366
else:
363-
unit = end.unit
367+
unit = cast("TimeUnit", end.unit)
364368
elif start is not None:
365369
start = Timedelta(start)
366-
unit = start.unit
370+
unit = cast("TimeUnit", start.unit)
367371
else:
368372
end = Timedelta(end)
369-
unit = end.unit
373+
unit = cast("TimeUnit", end.unit)
370374

371375
# Last we need to watch out for cases where the 'freq' implies a higher
372376
# unit than either start or end
373377
if freq is not None:
378+
freq = cast("Tick | Day", freq)
374379
creso = abbrev_to_npy_unit(unit)
375380
if freq._creso > creso:
376-
unit = freq.base.freqstr
381+
unit = cast("TimeUnit", freq.base.freqstr)
377382

378383
tdarr = TimedeltaArray._generate_range(
379384
start, end, periods, freq, closed=closed, unit=cast("TimeUnit", unit)

0 commit comments

Comments
 (0)