[ty] Distinguish typing.TypedDict from typing_extensions.TypedDict#25843
Merged
charliermarsh merged 9 commits intoJun 25, 2026
Conversation
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
|
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.47%. The percentage of expected errors that received a diagnostic held steady at 89.19%. The number of fully passing files held steady at 95/134. |
|
af703c8 to
899bf77
Compare
typing.TypedDict from typing_extensions.TypedDict
0749bca to
2da3cf2
Compare
2da3cf2 to
0e44f47
Compare
carljm
approved these changes
Jun 25, 2026
AlexWaygood
reviewed
Jun 25, 2026
Comment on lines
+296
to
+301
| (Self::TypedDict(_), "TypedDict", KnownModule::Typing) => { | ||
| Self::TypedDict(TypedDictModule::Typing) | ||
| } | ||
| (Self::TypedDict(_), "TypedDict", KnownModule::TypingExtensions) => { | ||
| Self::TypedDict(TypedDictModule::TypingExtensions) | ||
| } |
Member
There was a problem hiding this comment.
hmm, it feels quite unfortunate that we have to do this. It seems much less necessary for typeshed to pretend that typing_extension.TypedDict is the same as typing.TypedDict than it does for it to pretend that typing.Callable is the same as collections.abc.Callable. I've opened python/typeshed#15943 to see if we can improve the typeshed definitions here, which would allow us to get rid of this
AlexWaygood
added a commit
that referenced
this pull request
Jun 27, 2026
…and `typing_extensions.TypedDict` (#26435) ## Summary - `typing.TypedDict` and `typing_extensions.TypedDict` are (accurately) represented as two distinct symbols in the latest version of our vendored typeshed stubs, so we can get rid of the use of `rewrap_from_module` (which feels like a _bit_ of a hack, best avoided where possible) and instead register them as distinct special forms in the way we usually would. The only snag here is that the two special forms have the same name, so `SpecialFormType::from_name()` has to be refactored to return `&'static [Self]` instead of `Option<Self>`, and is renamed to `SpecialFormType::candidates_from_name` (the name "TypedDict" has two candidates: `typing.TypedDict` and `typing_extensions.TypedDict`). - Add `typing_extensions._TypedDict` as a `KnownClass`. This significantly simplifies `typed_dict_fallback_class_member` in `typed_dict.rs`. - Get rid of `TypedDictModule::Either`. We always treated it exactly the same as `TypedDictModule::Typing`. This is a followup to #25843
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.
Summary
This follows up on #25833. On Python 3.12, classes defined using
typing_extensions.TypedDicthave runtime attributes that classes defined usingtyping.TypedDictdo not, but we currently treat both definitions as the same special form.This keeps track of which
TypedDictdefinition was used for class-based, functional, inherited, generic, and dynamically created TypedDicts. Member lookup still uses the shared typeshed declarations first, then consultstyping_extensions._TypedDictonly for TypedDicts defined usingtyping_extensions.TypedDict. Their MRO and type relationships remain unchanged.The regression tests cover
typing.TypedDictversustyping_extensions.TypedDicton Python 3.12, verify thattyping.TypedDict.__closed__is unavailable on Python 3.13, and cover the standard-library attributes available on Python 3.15.