Add spec and tests for PEP 728#2068
Merged
JelleZijlstra merged 6 commits intopython:mainfrom Aug 17, 2025
Merged
Conversation
I mostly copied the spec from PEP 728, with light editing to remove references to "this PEP" and fix links. In a followup I plan to reorganize the TypedDict spec. The conformance tests primarily derive from the examples in the PEP.
| @@ -0,0 +1,139 @@ | |||
| conformant = "Fail" | |||
Contributor
There was a problem hiding this comment.
Suggested change
| conformant = "Fail" | |
| conformant = "Unsupported" |
erictraut
approved these changes
Aug 16, 2025
Collaborator
erictraut
left a comment
There was a problem hiding this comment.
Thanks for doing this!
| @@ -0,0 +1,347 @@ | |||
| # pyright: enableExperimentalFeatures=true | |||
Collaborator
There was a problem hiding this comment.
This can be removed once pyright 1.1.404 is released.
| ``A`` if ``B`` is :term:`structurally <structural>` assignable to | ||
| ``A``. This is true if and only if all of the following are satisfied: | ||
|
|
||
| * **[If no key with the same name can be found in ``B``, the 'extra_items' |
Collaborator
There was a problem hiding this comment.
Is this rule meant to be bolded? Just wondering why it gets special emphasis.
Member
Author
There was a problem hiding this comment.
It's because it's added to the previous rules; it's like this in the PEP. I'll clean this up when I rewrite the TypedDict spec in a followup.
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
sinon
reviewed
Aug 17, 2025
Co-authored-by: Rob Hand <146272+sinon@users.noreply.github.com>
JelleZijlstra
added a commit
to JelleZijlstra/typing
that referenced
this pull request
Aug 17, 2025
This is an edit of the TypedDict spec for clarity and flow. My goal was to unify the pieces of the spec that derive from the various PEPs into a coherent whole. I removed excessive examples and motivations: the spec should specify, not justify. The length of the spec chapter is reduced by more than half. This change is on top of python#2068 (adding PEP 728). The general approach I took is to first define the kinds of TypedDicts that can exist, then explain the syntax for defining TypedDicts, then discuss other aspects of TypedDict types. I introduce some new terminology around PEP 728 to make it easier to talk about the different kinds of TypedDict. TypedDicts are defined to have a property called openness, which can have three states: - Open: all TypedDicts prior to PEP 728 - Closed: no extra keys are allowed (closed=True) - With extra items: extra_items=... from PEP 728 I retained existing text where it made sense but also wrote some from scratch.
JelleZijlstra
added a commit
to JelleZijlstra/typing
that referenced
this pull request
Aug 17, 2025
This is an edit of the TypedDict spec for clarity and flow. My goal was to unify the pieces of the spec that derive from the various PEPs into a coherent whole. I removed excessive examples and motivations: the spec should specify, not justify. The length of the spec chapter is reduced by more than half. This change is on top of python#2068 (adding PEP 728). The general approach I took is to first define the kinds of TypedDicts that can exist, then explain the syntax for defining TypedDicts, then discuss other aspects of TypedDict types. I introduce some new terminology around PEP 728 to make it easier to talk about the different kinds of TypedDict. TypedDicts are defined to have a property called openness, which can have three states: - Open: all TypedDicts prior to PEP 728 - Closed: no extra keys are allowed (closed=True) - With extra items: extra_items=... from PEP 728 I retained existing text where it made sense but also wrote some from scratch.
facebook-github-bot
pushed a commit
to facebook/pyrefly
that referenced
this pull request
Aug 17, 2025
Summary: Updated conformance tests to pull in a few significant PRs: * python/typing#2067 (a fair number of small tweaks) * python/typing#2056 (new test file for dataclasses match_args) * python/typing#2068 (new test file for TypedDict extra items) Reviewed By: samwgoldman Differential Revision: D80424920 fbshipit-source-id: 3d8ac3e70aa86329f0d1adb1af2d2e0837bc5c4e
rchen152
pushed a commit
that referenced
this pull request
Oct 14, 2025
* spec: Rewrite TypedDict spec This is an edit of the TypedDict spec for clarity and flow. My goal was to unify the pieces of the spec that derive from the various PEPs into a coherent whole. I removed excessive examples and motivations: the spec should specify, not justify. The length of the spec chapter is reduced by more than half. This change is on top of #2068 (adding PEP 728). The general approach I took is to first define the kinds of TypedDicts that can exist, then explain the syntax for defining TypedDicts, then discuss other aspects of TypedDict types. I introduce some new terminology around PEP 728 to make it easier to talk about the different kinds of TypedDict. TypedDicts are defined to have a property called openness, which can have three states: - Open: all TypedDicts prior to PEP 728 - Closed: no extra keys are allowed (closed=True) - With extra items: extra_items=... from PEP 728 I retained existing text where it made sense but also wrote some from scratch. * Apply suggestions from code review Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com> * feedback * Carl feedback * more clarity --------- Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I mostly copied the spec from PEP 728, with light editing to remove references to "this PEP"
and fix links. In a followup I plan to reorganize the TypedDict spec.
The conformance tests primarily derive from the examples in the PEP.