mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-20 04:29:47 +00:00
[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:
parent
42adfd40ea
commit
3c8fb68765
11 changed files with 169 additions and 75 deletions
|
|
@ -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})
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue