@@ -2534,50 +2534,86 @@ def check(thing: Things) -> None:
25342534 return None # E: Statement is unreachable
25352535[builtins fixtures/enum.pyi]
25362536
2537- [case testSunderValueType]
2537+ [case testSunderValueTypeEllipsis]
2538+ from foo.bar import (
2539+ Basic, FromStub, InheritedInt, InheritedStr, InheritedFlag, InheritedIntFlag
2540+ )
2541+
2542+ reveal_type(Basic.FOO) # N: Revealed type is "Literal[foo.bar.Basic.FOO]?"
2543+ reveal_type(Basic.FOO.value) # N: Revealed type is "Literal[1]?"
2544+ reveal_type(Basic.FOO._value_) # N: Revealed type is "builtins.int"
2545+
2546+ reveal_type(FromStub.FOO) # N: Revealed type is "Literal[foo.bar.FromStub.FOO]?"
2547+ reveal_type(FromStub.FOO.value) # N: Revealed type is "builtins.int"
2548+ reveal_type(FromStub.FOO._value_) # N: Revealed type is "builtins.int"
2549+
2550+ reveal_type(InheritedInt.FOO) # N: Revealed type is "Literal[foo.bar.InheritedInt.FOO]?"
2551+ reveal_type(InheritedInt.FOO.value) # N: Revealed type is "builtins.int"
2552+ reveal_type(InheritedInt.FOO._value_) # N: Revealed type is "builtins.int"
2553+
2554+ reveal_type(InheritedStr.FOO) # N: Revealed type is "Literal[foo.bar.InheritedStr.FOO]?"
2555+ reveal_type(InheritedStr.FOO.value) # N: Revealed type is "builtins.str"
2556+ reveal_type(InheritedStr.FOO._value_) # N: Revealed type is "builtins.str"
2557+
2558+ reveal_type(InheritedFlag.FOO) # N: Revealed type is "Literal[foo.bar.InheritedFlag.FOO]?"
2559+ reveal_type(InheritedFlag.FOO.value) # N: Revealed type is "builtins.int"
2560+ reveal_type(InheritedFlag.FOO._value_) # N: Revealed type is "builtins.int"
2561+
2562+ reveal_type(InheritedIntFlag.FOO) # N: Revealed type is "Literal[foo.bar.InheritedIntFlag.FOO]?"
2563+ reveal_type(InheritedIntFlag.FOO.value) # N: Revealed type is "builtins.int"
2564+ reveal_type(InheritedIntFlag.FOO._value_) # N: Revealed type is "builtins.int"
2565+
2566+ [file foo/__init__.pyi]
2567+ [file foo/bar/__init__.pyi]
25382568from enum import Enum, IntEnum, StrEnum, Flag, IntFlag
25392569
25402570class Basic(Enum):
25412571 _value_: int
25422572 FOO = 1
25432573
2544- reveal_type(Basic.FOO) # N: Revealed type is "Literal[__main__.Basic.FOO]?"
2545- reveal_type(Basic.FOO.value) # N: Revealed type is "Literal[1]?"
2546- reveal_type(Basic.FOO._value_) # N: Revealed type is "builtins.int"
2547-
25482574class FromStub(Enum):
25492575 _value_: int
25502576 FOO = ...
25512577
2552- reveal_type(FromStub.FOO) # N: Revealed type is "Literal[__main__.FromStub.FOO]?"
2553- reveal_type(FromStub.FOO.value) # N: Revealed type is "builtins.int"
2554- reveal_type(FromStub.FOO._value_) # N: Revealed type is "builtins.int"
2555-
25562578class InheritedInt(IntEnum):
25572579 FOO = ...
25582580
2559- reveal_type(InheritedInt.FOO) # N: Revealed type is "Literal[__main__.InheritedInt.FOO]?"
2560- reveal_type(InheritedInt.FOO.value) # N: Revealed type is "builtins.int"
2561- reveal_type(InheritedInt.FOO._value_) # N: Revealed type is "builtins.int"
2562-
25632581class InheritedStr(StrEnum):
25642582 FOO = ...
25652583
2566- reveal_type(InheritedStr.FOO) # N: Revealed type is "Literal[__main__.InheritedStr.FOO]?"
2567- reveal_type(InheritedStr.FOO.value) # N: Revealed type is "builtins.str"
2568- reveal_type(InheritedStr.FOO._value_) # N: Revealed type is "builtins.str"
2569-
25702584class InheritedFlag(Flag):
25712585 FOO = ...
25722586
2573- reveal_type(InheritedFlag.FOO) # N: Revealed type is "Literal[__main__.InheritedFlag.FOO]?"
2574- reveal_type(InheritedFlag.FOO.value) # N: Revealed type is "builtins.int"
2575- reveal_type(InheritedFlag.FOO._value_) # N: Revealed type is "builtins.int"
2576-
25772587class InheritedIntFlag(IntFlag):
25782588 FOO = ...
2589+ [builtins fixtures/enum.pyi]
25792590
2580- reveal_type(InheritedIntFlag.FOO) # N: Revealed type is "Literal[__main__.InheritedIntFlag.FOO]?"
2581- reveal_type(InheritedIntFlag.FOO.value) # N: Revealed type is "builtins.int"
2582- reveal_type(InheritedIntFlag.FOO._value_) # N: Revealed type is "builtins.int"
2591+ [case testSunderValueTypeEllipsisNonStub]
2592+ from enum import Enum, StrEnum
2593+
2594+ class Basic(Enum):
2595+ _value_: int
2596+ FOO = 1
2597+
2598+ reveal_type(Basic.FOO) # N: Revealed type is "Literal[__main__.Basic.FOO]?"
2599+ reveal_type(Basic.FOO.value) # N: Revealed type is "Literal[1]?"
2600+ reveal_type(Basic.FOO._value_) # N: Revealed type is "builtins.int"
2601+
2602+ # TODO: this and below should produce diagnostics, Ellipsis is not assignable to int
2603+ # Now we do not check members against _value_ at all.
2604+
2605+ class FromStub(Enum):
2606+ _value_: int
2607+ FOO = ...
2608+
2609+ reveal_type(FromStub.FOO) # N: Revealed type is "Literal[__main__.FromStub.FOO]?"
2610+ reveal_type(FromStub.FOO.value) # N: Revealed type is "builtins.ellipsis"
2611+ reveal_type(FromStub.FOO._value_) # N: Revealed type is "builtins.int"
2612+
2613+ class InheritedStr(StrEnum):
2614+ FOO = ...
2615+
2616+ reveal_type(InheritedStr.FOO) # N: Revealed type is "Literal[__main__.InheritedStr.FOO]?"
2617+ reveal_type(InheritedStr.FOO.value) # N: Revealed type is "builtins.ellipsis"
2618+ reveal_type(InheritedStr.FOO._value_) # N: Revealed type is "builtins.ellipsis"
25832619[builtins fixtures/enum.pyi]
0 commit comments