Skip to content

Add Python 3.15 TypedDict attributes#15887

Merged
AlexWaygood merged 2 commits into
python:mainfrom
charliermarsh:charlie/add-python-315-typeddict-attributes
Jun 10, 2026
Merged

Add Python 3.15 TypedDict attributes#15887
AlexWaygood merged 2 commits into
python:mainfrom
charliermarsh:charlie/add-python-315-typeddict-attributes

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Python 3.15's PEP 728 implementation adds __closed__ and __extra_items__ to classes created by TypedDict.

This adds those version-gated class variables to _typeshed._type_checker_internals.TypedDictFallback and the obsolete typing._TypedDict compatibility copy.

This was found while implementing PEP 728 support in ty: astral-sh/ruff#25591 (comment)

@charliermarsh charliermarsh marked this pull request as ready for review June 10, 2026 16:04
Comment thread stdlib/_typeshed/_type_checker_internals.pyi Outdated
@github-actions

This comment has been minimized.

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit 32b95c1 into python:main Jun 10, 2026
58 checks passed
charliermarsh added a commit to astral-sh/ruff that referenced this pull request Jun 10, 2026
## Summary

This follows up on #25823 now that
[python/typeshed#15887](python/typeshed#15887)
has been merged and vendored by #25828.

This removes the hard-coded synthesis for `TypedDict.__closed__` and
`__extra_items__` and reads the declarations from typeshed instead.
Python 3.15 uses `_typeshed._type_checker_internals.TypedDictFallback`;
earlier versions fall back to `typing_extensions._TypedDict`, preserving
the backported attributes and existing behavior.
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