-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: remove ignore from pandas/tseries/frequencies.py II #53120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TYP: remove ignore from pandas/tseries/frequencies.py II #53120
Conversation
pandas/tseries/frequencies.py
Outdated
if isinstance(index, Index) and not isinstance(index, DatetimeIndex): | ||
if not hasattr(index, "dtype"): | ||
pass | ||
elif isinstance(index.dtype, object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.dtype is always an object
pandas/tseries/frequencies.py
Outdated
# "Union[ExtensionArray, ndarray[Any, Any]]", variable has type | ||
# "Union[DatetimeIndex, TimedeltaIndex, Series, DatetimeLikeArrayMixin]") | ||
index = index._values # type: ignore[assignment] | ||
index = cast("TimedeltaArray", index._values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this cant be right. TimedeltaIndex goes through the _TimedeltaFrequencyInferer path above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment. If I understand correctly, we only need to checkis_numeric_dtype(index.dtype)
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, looks like that should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for reviewing this pr.
thanks @natmokval |
…53120) * remove mypy ignore[assignment] and cast index to TimedeltaArray * remove check index.dtype is an object * remove cast to TimedeltaArray
…53120) * remove mypy ignore[assignment] and cast index to TimedeltaArray * remove check index.dtype is an object * remove cast to TimedeltaArray
Related to pr #52623, which doesn't work correctly.
mypy ignore[assignment] was removed from pandas/tseries/frequencies.py