-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-hightopic-typed-dicttopic-union-types
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.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-hightopic-typed-dicttopic-union-types