Skip to content
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

Merged

Conversation

natmokval
Copy link
Contributor

@natmokval natmokval commented May 6, 2023

Related to pr #52623, which doesn't work correctly.
mypy ignore[assignment] was removed from pandas/tseries/frequencies.py

@natmokval natmokval marked this pull request as ready for review May 6, 2023 17:39
if isinstance(index, Index) and not isinstance(index, DatetimeIndex):
if not hasattr(index, "dtype"):
pass
elif isinstance(index.dtype, object):
Copy link
Member

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

# "Union[ExtensionArray, ndarray[Any, Any]]", variable has type
# "Union[DatetimeIndex, TimedeltaIndex, Series, DatetimeLikeArrayMixin]")
index = index._values # type: ignore[assignment]
index = cast("TimedeltaArray", index._values)
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@jbrockmendel jbrockmendel merged commit 54fb77b into pandas-dev:main May 8, 2023
@jbrockmendel
Copy link
Member

thanks @natmokval

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
…53120)

* remove mypy ignore[assignment] and cast index to TimedeltaArray

* remove check index.dtype is an object

* remove cast to TimedeltaArray
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…53120)

* remove mypy ignore[assignment] and cast index to TimedeltaArray

* remove check index.dtype is an object

* remove cast to TimedeltaArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants