-
Notifications
You must be signed in to change notification settings - Fork 265
Add spec and tests for PEP 728 #2068
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
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" |
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.
conformant = "Fail" | |
conformant = "Unsupported" |
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.
Thanks for doing this!
@@ -0,0 +1,347 @@ | |||
# pyright: enableExperimentalFeatures=true |
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.
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' |
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.
Is this rule meant to be bolded? Just wondering why it gets special emphasis.
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.
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>
Co-authored-by: Rob Hand <146272+sinon@users.noreply.github.com>
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.
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.
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
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.