Skip to content

Experiment: remove IntFlag from enum.auto #12760

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

Merged
merged 4 commits into from
Oct 9, 2024
Merged

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Oct 9, 2024

comments in #10384 suggest that type checkers should special case enum.auto rather than relying on the IntFlag hack. It's been a while since then, do we still need it?

related to #3968

comments in python#10384 suggest
that type checkers should special case enum.auto rather than
relying on the IntFlag hack. It's been a while since then, do we
still need it?

This comment has been minimized.

@tungol tungol marked this pull request as draft October 9, 2024 03:06

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Oct 9, 2024

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@tungol tungol marked this pull request as ready for review October 9, 2024 04:17
@tungol
Copy link
Contributor Author

tungol commented Oct 9, 2024

Seems functional now. The comparison typing will incorrectly allow auto() | auto() within a StrEnum, but it's not very likely that someone would try. I don't think perfect typing of this is possible outside of special casing by the type checker, and with mypy it exists as auto within the class body scope, so it's pretty limited what someone might get up to.

@JelleZijlstra JelleZijlstra merged commit 3e29e05 into python:main Oct 9, 2024
63 checks passed
@tungol tungol deleted the enum branch October 9, 2024 04:36
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