Skip to content

Commit d9c1292

Browse files
committed
cast index to TimedeltaArray
1 parent 9103f70 commit d9c1292

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/tseries/frequencies.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING
3+
from typing import (
4+
TYPE_CHECKING,
5+
cast,
6+
)
47

58
import numpy as np
69

@@ -49,9 +52,9 @@
4952
from pandas import (
5053
DatetimeIndex,
5154
Series,
52-
TimedeltaArray,
5355
TimedeltaIndex,
5456
)
57+
from pandas.core.arrays import TimedeltaArray
5558
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
5659
# ---------------------------------------------------------------------
5760
# Offset names ("time rules") and related functions
@@ -177,7 +180,8 @@ def infer_freq(
177180
raise TypeError(
178181
f"cannot infer freq from a non-convertible index of dtype {index.dtype}"
179182
)
180-
index: TimedeltaArray = index
183+
184+
index = cast("TimedeltaArray", index)
181185

182186
if not isinstance(index, DatetimeIndex):
183187
index = DatetimeIndex(index)

0 commit comments

Comments
 (0)