You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use object for value annotation in Enum.__new__ (#7752)
This pull request reverts part of #2539 that brought back a bug discussed in python/mypy#5788 and initially fixed in #2539
In short, the issue was that the following program always resulted
in an error when running mypy with the `--disallow-any-expr` flag:
from enum import Enum
class MyEnum(Enum):
FOO = 1
BAR = 2
blah = MyEnum # Error here
The root issue was that because the signature of Enum's
`__new__` method was typed as:
def __new__(self: Type[T], value: Any) -> T: ...
This caused mypy to decide that the type of `MyEnum` was
`(Any) -> MyEnum`. This is correct based on the current
type signature, but unfortunately means that it becomes
impossible to ever use enums with the `--disallow-any-expr` flag.
0 commit comments