-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP 728: Revise proposal to spec the 'extra_items=T' idea #4066
Conversation
2482267
to
f5a5e90
Compare
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.
Thank you!
peps/pep-0728.rst
Outdated
<https://discuss.python.org/t/pep-728-typeddict-with-typed-extra-items/45443/115>`__. | ||
|
||
This will allow us to deprecate the functional syntax of defining TypedDict | ||
types altogether, but adapting to this proposal will make this PEP heavier. |
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.
I feel this isn't a strong argument; if this PEP is accepted, we'll be stuck with its behavior for at least many years, so we need to make sure we get it right the first time.
This proposal is nice because it also unlocks some other things that are currently awkward or impossible (keys that aren't valid identifiers), it has a few disadvantages:
- It's less apparent to a reader that
_: bool
makes the TypedDict special, relative to adding a class argument likeextra_items=bool
. - It's backwards incompatible with existing TypedDicts using the
_: bool
key. While such users have a way to get around the issue, it's still a problem for them if they upgrade Python (or typing-extensions). - The types don't appear in an annotation context, so their evaluation will not be deferred.
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.
Added the bullet points to this section in commit d146b98. Thanks!
python#4066 (comment) Signed-off-by: Zixuan James Li <[email protected]>
- Move away from '__extra_items__: T' to 'extra_items=T' - Repurpose the 'closed' class parameter to make 'closed=True' an alias of 'extra_items=Never' - Include references to the typing spec - Normalize terms like "assignability" and "consistent" to match the typing glossary (https://typing.readthedocs.io/en/latest/spec/glossary.html) - Update sections that contain documentation quotes to match the up-to-date version - Add new sections about other ideas - Bump the target version to 3.14
Some of the linked sections do not expose the label, otherwise we should be able to use intersphinx references. Signed-off-by: Zixuan James Li <[email protected]>
Signed-off-by: Zixuan James Li <[email protected]>
Signed-off-by: Zixuan James Li <[email protected]>
python#4066 (comment) Signed-off-by: Zixuan James Li <[email protected]>
PEP 123: Summary of changes
)Change summary
__extra_items__: T
toextra_items=T
📚 Documentation preview 📚: https://pep-previews--4066.org.readthedocs.build/