Closed
Description
The following example started generating a false positive after #9097:
from typing import TypedDict, Literal, Union
from enum import Enum
class E(Enum):
FOO = "a"
BAR = "b"
class Foo(TypedDict):
tag: Literal[E.FOO]
x: int
class Bar(TypedDict):
tag: Literal[E.BAR]
y: int
def f(d: Union[Foo, Bar]) -> None:
assert d['tag'] == E.FOO
d['x'] # TypedDict "Bar" has no key "x"
Type narrowing should work and there should be no error reported.