[ty] implement TypedDict structural assignment (#21467)

Closes https://github.com/astral-sh/ty/issues/1387.
This commit is contained in:
Jack O'Connor
2025-11-20 13:15:28 -08:00
committed by GitHub
parent 1b28fc1f14
commit eb7c098d6b
11 changed files with 678 additions and 59 deletions

View File

@@ -95,6 +95,7 @@ from typing import TypedDict
class Person(TypedDict):
name: str
phone_number: str
class Animal(TypedDict):
name: str
@@ -104,13 +105,14 @@ def _(being: Person | Animal) -> None:
being["legs"] = 4 # error: [invalid-key]
```
## Unknown key for all elemens of a union
## Unknown key for all elements of a union
```py
from typing import TypedDict
class Person(TypedDict):
name: str
phone_number: str
class Animal(TypedDict):
name: str