Skip to content

Comments

PEP 728: Revise proposal to spec the 'extra_items=T' idea#4066

Merged
JelleZijlstra merged 6 commits intopython:mainfrom
PIG208:pep-0728
Oct 19, 2024
Merged

PEP 728: Revise proposal to spec the 'extra_items=T' idea#4066
JelleZijlstra merged 6 commits intopython:mainfrom
PIG208:pep-0728

Conversation

@PIG208
Copy link
Contributor

@PIG208 PIG208 commented Oct 17, 2024

  • Change is either:
    • To a Draft PEP
    • To an Accepted or Final PEP, with Steering Council approval
    • To fix an editorial issue (markup, typo, link, header, etc)
  • PR title prefixed with PEP number (e.g. PEP 123: Summary of changes)

Change summary


📚 Documentation preview 📚: https://pep-previews--4066.org.readthedocs.build/

@PIG208 PIG208 requested a review from JelleZijlstra as a code owner October 17, 2024 23:30
@PIG208 PIG208 changed the title Revise proposal to spec the 'extra_items=T' idea PEP 728: Revise proposal to spec the 'extra_items=T' idea Oct 17, 2024
@PIG208 PIG208 force-pushed the pep-0728 branch 2 times, most recently from 2482267 to f5a5e90 Compare October 17, 2024 23:40
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thank you!

<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.
Copy link
Member

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 like extra_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.

Copy link
Contributor Author

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!

PIG208 added a commit to PIG208/peps that referenced this pull request Oct 18, 2024
- 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]>
@JelleZijlstra JelleZijlstra merged commit 5e67f84 into python:main Oct 19, 2024
@PIG208 PIG208 deleted the pep-0728 branch October 19, 2024 02:24
gvanrossum pushed a commit to gvanrossum/peps that referenced this pull request Dec 10, 2024
- 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

Signed-off-by: Zixuan James Li <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
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