Closed
Description
Minimal test case:
[case testTaggedUnionByKey]
from mypy_extensions import TypedDict
from typing import Union
class A(TypedDict):
foo: int
class B(TypedDict):
bar: str
def a(a: Union[A, B]):
return a["foo"] if "foo" in a else None
[builtins fixtures/tuple.pyi]
The code is checking if the key is present, so this should pass correctly, but instead fails with error: TypedDict "B" has no key 'foo'
.