Skip to content
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

Backport generic NamedTuple and TypedDict support #7

Closed
JelleZijlstra opened this issue May 3, 2022 · 5 comments · Fixed by #46
Closed

Backport generic NamedTuple and TypedDict support #7

JelleZijlstra opened this issue May 3, 2022 · 5 comments · Fixed by #46

Comments

@JelleZijlstra
Copy link
Member

Python 3.11 will support generic NamedTuples (python/cpython#92027) and TypedDicts (python/cpython#27663) at runtime. If there is community interest, we should backport support for these features into typing-extensions. I'm not planning to work on this myself but I'll accept patches.

@AlexWaygood
Copy link
Member

I'd be interested in working on this if nobody else wants to, but I've got quite a lot on for the next two weeks or so, so I'm happy to let somebody else tackle it if they can do it more promptly!

@Bluenix2
Copy link

Bluenix2 commented May 14, 2022

As discovered in Python Discord's #type-hinting channel (09/05/2022), typing_extensions 4.2 release appears to support this already.

That said, it appears to still be missing for Python 3.7 and 3.8. This CI run of mine is on Python 3.7 and locally I can reproduce it on my Python 3.8.10 installaton (py -3.8-64 -c "import discord_typings"):

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\%username%\Projects\discord-typings\discord_typings\__init__.py", line 5, in <module> 
    from .gateway import *
  File "C:\Users\%username%\Projects\discord-typings\discord_typings\gateway.py", line 267, in <module>
    ReadyEvent = GenericDispatchEvent[Literal['READY'], ReadyData]
TypeError: '_TypedDictMeta' object is not subscriptable

@JelleZijlstra
Copy link
Member Author

The current support is accidental, not tested, and doesn't cover all supported Python versions, so I don't think it really makes a difference.

@Bluenix2
Copy link

It gives hints as to what one could do to make this pass on all versions ☝️

@JelleZijlstra JelleZijlstra transferred this issue from python/typing May 19, 2022
@julien-blanchon
Copy link

I love this ! I hope TypedDict will also be include soon. Thanks you @JelleZijlstra @AlexWaygood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants