[ty] More precise type inference for dictionary literals (#20523)
## Summary Extends https://github.com/astral-sh/ruff/pull/20360 to dictionary literals. This also improves our `TypeDict` support by passing through nested type context.
This commit is contained in:
@@ -57,7 +57,7 @@ type("Foo", Base, {})
|
||||
# error: [invalid-argument-type] "Argument to class `type` is incorrect: Expected `tuple[type, ...]`, found `tuple[Literal[1], Literal[2]]`"
|
||||
type("Foo", (1, 2), {})
|
||||
|
||||
# TODO: this should be an error
|
||||
# error: [invalid-argument-type] "Argument to class `type` is incorrect: Expected `dict[str, Any]`, found `dict[Unknown | bytes, Unknown | int]`"
|
||||
type("Foo", (Base,), {b"attr": 1})
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user