[ty] dict is not assignable to TypedDict (#21238)
## Summary A lot of the bidirectional inference work relies on `dict` not being assignable to `TypedDict`, so I think it makes sense to add this before fully implementing https://github.com/astral-sh/ty/issues/1387.
This commit is contained in:
@@ -1685,8 +1685,7 @@ def int_or_str() -> int | str:
|
||||
x = f([{"x": 1}], int_or_str())
|
||||
reveal_type(x) # revealed: int | str
|
||||
|
||||
# TODO: error: [no-matching-overload] "No overload of function `f` matches arguments"
|
||||
# we currently incorrectly consider `list[dict[str, int]]` a subtype of `list[T]`
|
||||
# error: [no-matching-overload] "No overload of function `f` matches arguments"
|
||||
f([{"y": 1}], int_or_str())
|
||||
```
|
||||
|
||||
|
||||
@@ -277,7 +277,6 @@ def _(flag: bool):
|
||||
x = f({"x": 1})
|
||||
reveal_type(x) # revealed: int
|
||||
|
||||
# TODO: error: [invalid-argument-type] "Argument to function `f` is incorrect: Expected `T`, found `dict[str, int]`"
|
||||
# we currently consider `TypedDict` instances to be subtypes of `dict`
|
||||
# error: [invalid-argument-type] "Argument to function `f` is incorrect: Expected `T`, found `dict[Unknown | str, Unknown | int]`"
|
||||
f({"y": 1})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user