Support recursive TypedDicts#13373
Conversation
This comment has been minimized.
This comment has been minimized.
|
The |
This comment has been minimized.
This comment has been minimized.
JukkaL
left a comment
There was a problem hiding this comment.
Not a full review -- left some ideas about additional tests.
| b: TDB | ||
|
|
||
| td: TD | ||
| reveal_type(td) # N: Revealed type is "TypedDict('__main__.TD', {'xb': builtins.int, 'yb': ..., 'xa': builtins.int, 'ya': ..., 'a': TypedDict('__main__.TDA', {'xa': builtins.int, 'ya': ...}), 'b': TypedDict('__main__.TDB', {'xb': builtins.int, 'yb': ...})})" |
There was a problem hiding this comment.
Test constructing recursive TypedDicts, e.g. TD(...) (with different levels of nesting) and td: TD = {...}.
Test calling some methods on recursive typeddicts.
Test indexed assignment to a recursive typeddict.
| == | ||
| b.py:3: error: Unsupported operand types for + ("int" and "str") | ||
|
|
||
| [case testTypedDictUpdate3] |
There was a problem hiding this comment.
Test coarse-grained incremental checking with recursive TypedDicts (i.e. serialization).
|
Well it looks like merging didn't go perfect. Anyway the diff is correct, it is just the commit history shown includes commits from the previous PR. I added a bunch of tests as requested plus also some basic subtyping and joins. |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
JukkaL
left a comment
There was a problem hiding this comment.
LGTM, thanks for the PR! Recursive TypedDicts are a nice feature.
This is a continuation of #13297
Depends on #13371
It was actually quite easy, essentially just a 1-to-1 mapping from the other PR. I will rebase when the first PR will be merged.
cc @JukkaL