[ty] implement TypedDict structural assignment (#21467)
Closes https://github.com/astral-sh/ty/issues/1387.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user