File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
crates/ty_python_semantic/resources/mdtest Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 44
55``` py
66from enum import Enum
7+ from typing import Literal
78
89class Color (Enum ):
910 RED = 1
@@ -13,6 +14,14 @@ class Color(Enum):
1314reveal_type(Color.RED ) # revealed: Literal[Color.RED]
1415# TODO : This could be `Literal[1]`
1516reveal_type(Color.RED .value) # revealed: Any
17+ # TODO : This could be `Literal[1]`
18+ reveal_type(Color.RED ._value_) # revealed: Any
19+
20+ # TODO : Literal["RED"]
21+ reveal_type(Color.RED .name) # revealed: Any
22+
23+ # TODO : Literal["RED"]
24+ reveal_type(Color.RED ._name_) # revealed: str
1625
1726# TODO : Should be `Color` or `Literal[Color.RED]`
1827reveal_type(Color[" RED" ]) # revealed: Unknown
@@ -21,6 +30,14 @@ reveal_type(Color["RED"]) # revealed: Unknown
2130reveal_type(Color(1 )) # revealed: Color
2231
2332reveal_type(Color.RED in Color) # revealed: bool
33+
34+ def func1 (red_or_blue : Literal[Color.RED , Color.BLUE ]):
35+ # TODO : Literal["RED", "BLUE"]
36+ reveal_type(red_or_blue.name) # revealed: Any
37+
38+ def func2 (any_color : Color):
39+ # TODO : Literal["RED", "GREEN", "BLUE"]
40+ reveal_type(any_color.name) # revealed: Any
2441```
2542
2643## Enum members
You can’t perform that action at this time.
0 commit comments