Skip to content
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

Merged
merged 15 commits into from
Aug 11, 2022
Merged

Conversation

ilevkivskyi
Copy link
Member

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

@github-actions

This comment has been minimized.

@ilevkivskyi
Copy link
Member Author

The mypy_primer effect is all from base PR, so the effect of this one is zero.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL left a 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': ...})})"
Copy link
Collaborator

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]
Copy link
Collaborator

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).

@ilevkivskyi
Copy link
Member Author

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.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@JukkaL JukkaL left a 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.

@ilevkivskyi ilevkivskyi merged commit cba07d7 into python:master Aug 11, 2022
@ilevkivskyi ilevkivskyi deleted the recursive-typed-dicts branch August 11, 2022 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants