-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
topic-type-narrowingConditional type narrowing / binderConditional type narrowing / bindertopic-typed-dict
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'.
Metadata
Metadata
Assignees
Labels
topic-type-narrowingConditional type narrowing / binderConditional type narrowing / bindertopic-typed-dict