Skip to content

Experiment: remove IntFlag from enum.auto - #12760

Merged
JelleZijlstra merged 4 commits into
python:mainfrom
tungol:enum
Oct 9, 2024
Merged

JelleZijlstra merged 4 commits into
python:mainfrom
tungol:enum

Conversation

@tungol

@tungol tungol commented Oct 9, 2024

Copy link
Copy Markdown
Contributor

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?
@github-actions

This comment has been minimized.

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

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 9, 2024

Copy link
Copy Markdown
Contributor

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

tungol commented Oct 9, 2024

Copy link
Copy Markdown
Contributor Author

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
@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