@@ -6,7 +6,7 @@ class Medal(Enum):
66 gold = 1
77 silver = 2
88 bronze = 3
9- reveal_type(Medal.bronze) # N: Revealed type is '__main__.Medal* '
9+ reveal_type(Medal.bronze) # N: Revealed type is 'Literal[ __main__.Medal.bronze]? '
1010m = Medal.gold
1111if int():
1212 m = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "Medal")
@@ -20,7 +20,7 @@ class Medal(metaclass=EnumMeta):
2020 # Without __init__ the definition fails at runtime, but we want to verify that mypy
2121 # uses `enum.EnumMeta` and not `enum.Enum` as the definition of what is enum.
2222 def __init__(self, *args): pass
23- reveal_type(Medal.bronze) # N: Revealed type is '__main__.Medal'
23+ reveal_type(Medal.bronze) # N: Revealed type is 'Literal[ __main__.Medal.bronze]? '
2424m = Medal.gold
2525if int():
2626 m = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "Medal")
@@ -34,7 +34,7 @@ class Medal(Achievement):
3434 bronze = None
3535 # See comment in testEnumFromEnumMetaBasics
3636 def __init__(self, *args): pass
37- reveal_type(Medal.bronze) # N: Revealed type is '__main__.Medal'
37+ reveal_type(Medal.bronze) # N: Revealed type is 'Literal[ __main__.Medal.bronze]? '
3838m = Medal.gold
3939if int():
4040 m = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "Medal")
@@ -53,7 +53,7 @@ class Truth(Enum):
5353 false = False
5454x = ''
5555x = Truth.true.name
56- reveal_type(Truth.true.name) # N: Revealed type is 'builtins.str '
56+ reveal_type(Truth.true.name) # N: Revealed type is 'Literal['true']? '
5757reveal_type(Truth.false.value) # N: Revealed type is 'builtins.bool'
5858[builtins fixtures/bool.pyi]
5959
@@ -246,7 +246,7 @@ class A:
246246a = A()
247247reveal_type(a.x)
248248[out]
249- main:8: note: Revealed type is '__main__.E@4* '
249+ main:8: note: Revealed type is '__main__.E@4'
250250
251251[case testEnumInClassBody]
252252from enum import Enum
@@ -270,9 +270,9 @@ reveal_type(E.bar.value)
270270reveal_type(I.bar)
271271reveal_type(I.baz.value)
272272[out]
273- main:4: note: Revealed type is '__main__.E* '
273+ main:4: note: Revealed type is 'Literal[ __main__.E.foo]? '
274274main:5: note: Revealed type is 'Any'
275- main:6: note: Revealed type is '__main__.I* '
275+ main:6: note: Revealed type is 'Literal[ __main__.I.bar]? '
276276main:7: note: Revealed type is 'builtins.int'
277277
278278[case testFunctionalEnumListOfStrings]
@@ -282,8 +282,8 @@ F = IntEnum('F', ['bar', 'baz'])
282282reveal_type(E.foo)
283283reveal_type(F.baz)
284284[out]
285- main:4: note: Revealed type is '__main__.E* '
286- main:5: note: Revealed type is '__main__.F* '
285+ main:4: note: Revealed type is 'Literal[ __main__.E.foo]? '
286+ main:5: note: Revealed type is 'Literal[ __main__.F.baz]? '
287287
288288[case testFunctionalEnumListOfPairs]
289289from enum import Enum, IntEnum
@@ -294,10 +294,10 @@ reveal_type(F.baz)
294294reveal_type(E.foo.value)
295295reveal_type(F.bar.name)
296296[out]
297- main:4: note: Revealed type is '__main__.E* '
298- main:5: note: Revealed type is '__main__.F* '
299- main:6: note: Revealed type is 'builtins.int '
300- main:7: note: Revealed type is 'builtins.str '
297+ main:4: note: Revealed type is 'Literal[ __main__.E.foo]? '
298+ main:5: note: Revealed type is 'Literal[ __main__.F.baz]? '
299+ main:6: note: Revealed type is 'Literal[1]? '
300+ main:7: note: Revealed type is 'Literal['bar']? '
301301
302302[case testFunctionalEnumDict]
303303from enum import Enum, IntEnum
@@ -308,10 +308,10 @@ reveal_type(F.baz)
308308reveal_type(E.foo.value)
309309reveal_type(F.bar.name)
310310[out]
311- main:4: note: Revealed type is '__main__.E* '
312- main:5: note: Revealed type is '__main__.F* '
313- main:6: note: Revealed type is 'builtins.int '
314- main:7: note: Revealed type is 'builtins.str '
311+ main:4: note: Revealed type is 'Literal[ __main__.E.foo]? '
312+ main:5: note: Revealed type is 'Literal[ __main__.F.baz]? '
313+ main:6: note: Revealed type is 'Literal[1]? '
314+ main:7: note: Revealed type is 'Literal['bar']? '
315315
316316[case testFunctionalEnumErrors]
317317from enum import Enum, IntEnum
@@ -363,10 +363,10 @@ main:22: error: "Type[W]" has no attribute "c"
363363from enum import Flag, IntFlag
364364A = Flag('A', 'x y')
365365B = IntFlag('B', 'a b')
366- reveal_type(A.x) # N: Revealed type is '__main__.A* '
367- reveal_type(B.a) # N: Revealed type is '__main__.B* '
368- reveal_type(A.x.name) # N: Revealed type is 'builtins.str '
369- reveal_type(B.a.name) # N: Revealed type is 'builtins.str '
366+ reveal_type(A.x) # N: Revealed type is 'Literal[ __main__.A.x]? '
367+ reveal_type(B.a) # N: Revealed type is 'Literal[ __main__.B.a]? '
368+ reveal_type(A.x.name) # N: Revealed type is 'Literal['x']? '
369+ reveal_type(B.a.name) # N: Revealed type is 'Literal['a']? '
370370
371371# TODO: The revealed type should be 'int' here
372372reveal_type(A.x.value) # N: Revealed type is 'Any'
@@ -381,7 +381,7 @@ class A:
381381a = A()
382382reveal_type(a.x)
383383[out]
384- main:7: note: Revealed type is '__main__.A.E@4* '
384+ main:7: note: Revealed type is '__main__.A.E@4'
385385
386386[case testFunctionalEnumInClassBody]
387387from enum import Enum
@@ -451,19 +451,19 @@ F = Enum('F', 'a b')
451451[rechecked]
452452[stale]
453453[out1]
454- main:2: note: Revealed type is 'm.E* '
455- main:3: note: Revealed type is 'm.F* '
454+ main:2: note: Revealed type is 'Literal[ m.E.a]? '
455+ main:3: note: Revealed type is 'Literal[ m.F.b]? '
456456[out2]
457- main:2: note: Revealed type is 'm.E* '
458- main:3: note: Revealed type is 'm.F* '
457+ main:2: note: Revealed type is 'Literal[ m.E.a]? '
458+ main:3: note: Revealed type is 'Literal[ m.F.b]? '
459459
460460[case testEnumAuto]
461461from enum import Enum, auto
462462class Test(Enum):
463463 a = auto()
464464 b = auto()
465465
466- reveal_type(Test.a) # N: Revealed type is '__main__.Test* '
466+ reveal_type(Test.a) # N: Revealed type is 'Literal[ __main__.Test.a]? '
467467[builtins fixtures/primitives.pyi]
468468
469469[case testEnumAttributeAccessMatrix]
@@ -689,31 +689,31 @@ else:
689689
690690if x is z:
691691 reveal_type(x) # N: Revealed type is 'Literal[__main__.Foo.A]'
692- reveal_type(z) # N: Revealed type is '__main__.Foo* '
692+ reveal_type(z) # N: Revealed type is 'Literal[ __main__.Foo.A]? '
693693 accepts_foo_a(z)
694694else:
695695 reveal_type(x) # N: Revealed type is 'Union[Literal[__main__.Foo.B], Literal[__main__.Foo.C]]'
696- reveal_type(z) # N: Revealed type is '__main__.Foo* '
696+ reveal_type(z) # N: Revealed type is 'Literal[ __main__.Foo.A]? '
697697 accepts_foo_a(z)
698698if z is x:
699699 reveal_type(x) # N: Revealed type is 'Literal[__main__.Foo.A]'
700- reveal_type(z) # N: Revealed type is '__main__.Foo* '
700+ reveal_type(z) # N: Revealed type is 'Literal[ __main__.Foo.A]? '
701701 accepts_foo_a(z)
702702else:
703703 reveal_type(x) # N: Revealed type is 'Union[Literal[__main__.Foo.B], Literal[__main__.Foo.C]]'
704- reveal_type(z) # N: Revealed type is '__main__.Foo* '
704+ reveal_type(z) # N: Revealed type is 'Literal[ __main__.Foo.A]? '
705705 accepts_foo_a(z)
706706
707707if y is z:
708708 reveal_type(y) # N: Revealed type is 'Literal[__main__.Foo.A]'
709- reveal_type(z) # N: Revealed type is '__main__.Foo* '
709+ reveal_type(z) # N: Revealed type is 'Literal[ __main__.Foo.A]? '
710710 accepts_foo_a(z)
711711else:
712712 reveal_type(y) # No output: this branch is unreachable
713713 reveal_type(z) # No output: this branch is unreachable
714714if z is y:
715715 reveal_type(y) # N: Revealed type is 'Literal[__main__.Foo.A]'
716- reveal_type(z) # N: Revealed type is '__main__.Foo* '
716+ reveal_type(z) # N: Revealed type is 'Literal[ __main__.Foo.A]? '
717717 accepts_foo_a(z)
718718else:
719719 reveal_type(y) # No output: this branch is unreachable
0 commit comments