Marking a private `Enum` member as `member()` does not work
Open
@sobolevn is already working on this.
Since Jan 29, 2025.
bug
topic-enum
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Consider this example:
from enum import Enum, member
class Pet(Enum):
__CAT = member(1)
reveal_type(Pet.__CAT) # N: Revealed type is "enum.member[Literal[1]?]"
Link: https://mypy-play.net/?mypy=latest&python=3.12&gist=63b056215c22ba7ff09e2559dd2ae08a
However, in runtimes it fails with AttributeError, because __CAT is mangled to _Pet__CAT as regular private names are.
We need to fix this corner-case.
Refs https://github.com/python/mypy/issues/18491
Refs https://github.com/python/mypy/issues/18557
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.