Skip to content

Commit 57db925

Browse files
committed
Add negative test
1 parent 1cfb130 commit 57db925

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test-data/unit/check-typeddict.test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,9 +4297,13 @@ class TD(TypedDict):
42974297
x: int
42984298

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

4301-
def accepts_td(d: Union[TD, dict[str, str]]) -> None: ...
4302+
def ok(d: Union[TD, dict[str, str]]) -> None: ...
4303+
ok({"x": "foo"})
4304+
4305+
def bad(d: Union[TD, dict[str, int]]) -> None: ...
4306+
bad({"x": "foo"}) # E: Dict entry 0 has incompatible type "str": "str"; expected "str": "int"
43024307

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

0 commit comments

Comments
 (0)