mirror of https://github.com/astral-sh/ruff
## Summary
Validates writes to `TypedDict` keys, for example:
```py
class Person(TypedDict):
name: str
age: int | None
def f(person: Person):
person["naem"] = "Alice" # error: [invalid-key]
person["age"] = "42" # error: [invalid-assignment]
```
The new specialized `invalid-assignment` diagnostic looks like this:
<img width="1160" height="279" alt="image"
src="https://github.com/user-attachments/assets/51259455-3501-4829-a84e-df26ff90bd89"
/>
## Ecosystem analysis
As far as I can tell, all true positives!
There are some extremely long diagnostic messages. We should truncate
our display of overload sets somehow.
## Test Plan
New Markdown tests
|
||
|---|---|---|
| .. | ||
| .gitattributes | ||
| cli.md | ||
| configuration.md | ||
| environment.md | ||
| mypy_primer.md | ||
| rules.md | ||
| tracing-flamegraph.png | ||
| tracing.md | ||