typing icon indicating copy to clipboard operation
typing copied to clipboard

TypedDict with patterns as key names

Open abersheeran opened this issue 4 years ago • 8 comments

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?

abersheeran avatar Apr 05 '21 11:04 abersheeran

Can you bring this idea up on typing-sig?

gvanrossum avatar Apr 05 '21 15:04 gvanrossum

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

abersheeran avatar Apr 05 '21 16:04 abersheeran

@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/.

JelleZijlstra avatar Apr 05 '21 16:04 JelleZijlstra

@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 avatar Apr 07 '21 04:04 abersheeran

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

abersheeran avatar Apr 09 '21 03:04 abersheeran

I found two old issue about this. https://github.com/python/mypy/issues/7654 https://github.com/python/mypy/issues/4617

abersheeran avatar Jul 28 '21 02:07 abersheeran

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

Rocamonde avatar Jul 19 '22 00:07 Rocamonde

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.

JelleZijlstra avatar Jul 19 '22 00:07 JelleZijlstra