Skip to content

Conversation

Dr-Irv
Copy link
Contributor

@Dr-Irv Dr-Irv commented Aug 19, 2025

mypy is fixing how they handle enum types, and the fix revealed an issue with how we handle them.

See python/mypy#19687 (comment)

@vam5h1

This comment was marked as off-topic.

@@ -1435,11 +1435,11 @@ def _range_from_fields(
if quarter is not None:
if freq is None:
freq = to_offset("Q", is_period=True)
base = FreqGroup.FR_QTR.value
base = cast(int, FreqGroup.FR_QTR.value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is a mypy bug and is no longer necessary on mypy master (python/mypy#19352), so the next release will cause [redundant-cast] here and below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I made the changes in this PR to address the future mypy, but we need the code to work now with the current mypy and so that the changes made in the dev version of mypy work with pandas.

@@ -74,6 +74,44 @@
"pandas._libs.tslibs.offsets.BusinessHour.rollforward ",
# type alias
"pandas._libs.tslibs.timedeltas.UnitChoices",
# enum types in cython vs PYI
"pandas._libs.tslibs.dtypes.FreqGroup.FR_ANN",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better, that same PR made all these entries redundant as well - current stubtest on mypy master does not report them as incompatible.

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.

4 participants