ruff/crates/ty/docs
David Peter 98df62db79
[ty] Validate writes to TypedDict keys (#19782)
## 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
2025-08-06 15:19:13 -07:00
..
.gitattributes [ty] Mark generated files as such in .gitattributes (#18195) 2025-05-19 16:50:48 +02:00
cli.md [ty] Allow -qq for silent output mode (#19366) 2025-07-15 17:08:19 +00:00
configuration.md [ty] Add an empty line to separate bullet points (#19195) 2025-07-08 05:10:31 +00:00
environment.md Auto-generate environment variable references for ty (#19205) 2025-07-08 10:48:31 -04:00
mypy_primer.md [ty] Update mypy_primer doc (#18638) 2025-06-11 20:50:37 -07:00
rules.md [ty] Validate writes to TypedDict keys (#19782) 2025-08-06 15:19:13 -07:00
tracing-flamegraph.png Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
tracing.md [ty] Minor typo in environment variable name (#17848) 2025-05-05 10:25:48 +00:00