Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Marking a private Enum member as member() does not work #18563

Description

@sobolevn

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 #18491
Refs #18557

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions