Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add negative test
  • Loading branch information
sterliakov committed Aug 4, 2025
commit 57db925d62d9f1573b2dab1c967ef6ce05632d80
8 changes: 6 additions & 2 deletions test-data/unit/check-typeddict.test
Original file line number Diff line number Diff line change
Expand Up @@ -4297,9 +4297,13 @@ class TD(TypedDict):
x: int

x: Union[TD, dict[str, str]] = {"x": "foo"}
y: Union[TD, dict[str, int]] = {"x": "foo"} # E: Dict entry 0 has incompatible type "str": "str"; expected "str": "int"

def accepts_td(d: Union[TD, dict[str, str]]) -> None: ...
def ok(d: Union[TD, dict[str, str]]) -> None: ...
ok({"x": "foo"})

def bad(d: Union[TD, dict[str, int]]) -> None: ...
bad({"x": "foo"}) # E: Dict entry 0 has incompatible type "str": "str"; expected "str": "int"

accepts_td({"x": "foo"})
[builtins fixtures/dict.pyi]
[typing fixtures/typing-typeddict.pyi]
Loading