We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Enum
member()
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.
AttributeError
__CAT
_Pet__CAT
We need to fix this corner-case.
Refs #18491 Refs #18557
The text was updated successfully, but these errors were encountered:
member
nonmember
TypeInfo.enum_members
I also think that the revealed type should be just Literal[1] ...?
Literal[1]
Sorry, something went wrong.
PR #16715 deals with name mangling. Would it fix this issue as well?
Yes, this problem is not related to Enum. It happens for all similar case:
from enum import Enum class A: def __init__(self) -> None: self.__private = 1 A().__private # false positive
sobolevn
No branches or pull requests
Consider this example:
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
The text was updated successfully, but these errors were encountered: