Skip to content

synthesize __required_keys__ and __optional_keys__ for TypedDicts#4085

Closed
yangdanny97 wants to merge 1 commit into
facebook:mainfrom
yangdanny97:export-D111085718
Closed

synthesize __required_keys__ and __optional_keys__ for TypedDicts#4085
yangdanny97 wants to merge 1 commit into
facebook:mainfrom
yangdanny97:export-D111085718

Conversation

@yangdanny97

Copy link
Copy Markdown
Contributor

Summary:
During attribute lookup we fall back to dict instead of TypedDictFallback for TypedDicts, which is a usability tradeoff since dict more closely models the runtime value but allows some operations (mutation) that may not be safe.

Unfortunately it means that some things only present on TypedDicts are missing, so this diff synthesizes them.

fixes #3745

Differential Revision: D111085718

Summary:
During attribute lookup we fall back to `dict` instead of `TypedDictFallback` for TypedDicts, which is a usability tradeoff since dict more closely models the runtime value but allows some operations (mutation) that may not be safe.

Unfortunately it means that some things only present on TypedDicts are missing, so this diff synthesizes them.

fixes facebook#3745

Differential Revision: D111085718
@meta-cla meta-cla Bot added the cla signed label Jul 8, 2026
@meta-codesync

meta-codesync Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@yangdanny97 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D111085718.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@grievejia grievejia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@grievejia grievejia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in bab341d Jul 13, 2026
@meta-codesync meta-codesync Bot added the Merged label Jul 13, 2026
@meta-codesync

meta-codesync Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in bab341d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants