Skip to content

TypedDict with patterns as key names #795

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

Open
abersheeran opened this issue Apr 5, 2021 · 8 comments
Open

TypedDict with patterns as key names #795

abersheeran opened this issue Apr 5, 2021 · 8 comments
Labels
topic: feature Discussions about new features for Python's type annotations

Comments

@abersheeran
Copy link

I'm not sure if I should open an issue here at typing, please let me know if there is something better.

WSGI type defines. https://gist.github.com/abersheeran/f3723029387fe7f6584c6b157b90a50a

When writing a more static WSGI definition based on PEP3333, I discovered such a problem. TypedDict cannot describe the HTTP_* keys in the WSGI specification. I know that one of the original intentions of TypedDict is to prevent typing the wrong keys. But can we add an option (for example: allow_undefined=True) to allow this actual problem?

@gvanrossum
Copy link
Member

Can you bring this idea up on typing-sig?

@abersheeran
Copy link
Author

Sorry, I don't quite understand what you mean, can you elaborate more?

@JelleZijlstra
Copy link
Member

@abersheeran Guido is referring to the typing-sig mailing list, which you can sign up for at https://mail.python.org/mailman3/lists/typing-sig.python.org/.

@abersheeran
Copy link
Author

@abersheeran Guido is referring to the typing-sig mailing list, which you can sign up for at https://mail.python.org/mailman3/lists/typing-sig.python.org/.

Thanks for your explanation.

@abersheeran
Copy link
Author

Related discussion:https://mail.python.org/archives/list/[email protected]/thread/LMZAPV5THQV6MXXO43RMGRRPFJ7TGYQN/

@abersheeran
Copy link
Author

I found two old issue about this. python/mypy#7654 python/mypy#4617

@srittau srittau added the topic: feature Discussions about new features for Python's type annotations label Nov 4, 2021
@srittau srittau changed the title [Feature Request] More forgiving TypedDict TypedDict with patterns as key names Nov 4, 2021
@Rocamonde
Copy link

What is the progress / status of this? I would find it extremely useful.

@JelleZijlstra
Copy link
Member

There is no active work I'm aware of in this area. If you want to move it forward, you'll have to build support among the typing community and eventually write a PEP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: feature Discussions about new features for Python's type annotations
Projects
None yet
Development

No branches or pull requests

5 participants