-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support recursive TypedDicts #13373
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -3504,6 +3528,35 @@ def foo(x: Point) -> int: | |||
== | |||
b.py:3: error: Unsupported operand types for + ("int" and "str") | |||
|
|||
[case testTypedDictUpdate3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 🤖🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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