Skip to content

Commit 97531ec

Browse files
committed
remove ignore[assignment] from pandas/tseries/frequencies.py II
1 parent 893ffa9 commit 97531ec

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pandas/tseries/frequencies.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from pandas import (
5050
DatetimeIndex,
5151
Series,
52+
TimedeltaArray,
5253
TimedeltaIndex,
5354
)
5455
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
@@ -140,10 +141,7 @@ def infer_freq(
140141
>>> pd.infer_freq(idx)
141142
'D'
142143
"""
143-
from pandas.core.api import (
144-
DatetimeIndex,
145-
Index,
146-
)
144+
from pandas.core.api import DatetimeIndex
147145

148146
if isinstance(index, ABCSeries):
149147
values = index._values
@@ -173,13 +171,14 @@ def infer_freq(
173171
inferer = _TimedeltaFrequencyInferer(index)
174172
return inferer.get_freq()
175173

176-
if isinstance(index, Index) and not isinstance(index, DatetimeIndex):
177-
values = index._values
174+
if not hasattr(index, "dtype"):
175+
pass
176+
elif isinstance(index.dtype, object):
178177
if index.dtype.kind in "iufcb":
179178
raise TypeError(
180179
f"cannot infer freq from a non-convertible index of dtype {index.dtype}"
181180
)
182-
index = values
181+
index: TimedeltaArray = index
183182

184183
if not isinstance(index, DatetimeIndex):
185184
index = DatetimeIndex(index)

0 commit comments

Comments
 (0)