Skip to content

Commit b2d6f35

Browse files
committed
test that structural assignment works for recursive TypedDicts too
1 parent 8b0a217 commit b2d6f35

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/ty_python_semantic/resources/mdtest/typed_dict.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,20 @@ nested: Node = {"name": "n1", "parent": {"name": "n2", "parent": {"name": "n3",
12461246
nested_invalid: Node = {"name": "n1", "parent": {"name": "n2", "parent": {"name": 3, "parent": None}}}
12471247
```
12481248

1249+
Structural assignment works for recursive `TypedDict`s too:
1250+
1251+
```py
1252+
class Person(TypedDict):
1253+
name: str
1254+
parent: Person | None
1255+
1256+
def _(node: Node, person: Person):
1257+
_: Person = node
1258+
_: Node = person
1259+
1260+
_: Node = Person(name="Alice", parent=Node(name="Bob", parent=Person(name="Charlie", parent=None)))
1261+
```
1262+
12491263
## Function/assignment syntax
12501264

12511265
This is not yet supported. Make sure that we do not emit false positives for this syntax:

0 commit comments

Comments
 (0)