-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Feature
Currently, passing an enum into its own constructor forgets its value:
from enum import IntEnum
class Foo(IntEnum):
x = 0
y = 1
reveal_type(Foo(Foo.x)) # reveals Foo, not Foo.x
reveal_type(Foo.__new__) # "def [Self <: IntEnum] (cls: type[Self], value: builtins.int) -> Self"
reveal_type(Foo.__init__) # "def (self: builtins.object)"
Pitch
It should be straightforward to synthesize a signature that makes Foo(Foo.x)
inferred as Foo.x
.