Basic support for typing_extensions.NamedTuple
#13178
Merged
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.
Description
This PR adds basic support for
typing_extensions.NamedTuple
, added to thetyping_extensions
runtime in python/typing_extensions@7c28357 and added to the typeshed stub in python/typeshed@10f3238.This PR doesn't add support for generic
NamedTuple
s: that'll have to come later. For now, it just teaches mypy thattyping_extensions.NamedTuple
should be treated much the same astyping.NamedTuple
in nearly all circumstances.I haven't cherry-picked the typeshed change in this PR (which was cherry-picked to the
0.970
branch in #13149, but doesn't exist onmaster
yet). It turned out I didn't need to do the cherry-pick in order for the tests to pass. I'm happy to do the cherry-pick as part of this PR if it's desirable, but I assume this PR comes too late to make it into release 0.970, and I assume there'll be another typeshed sync before release 0.980 comes out.Test Plan
I added a test making sure that all the basics work as expected, but didn't try to duplicate all tests relating to
typing.NamedTuple
(a similar approach to the one taken in #12602 fortyping_extensions.overload
).