Why can’t we …? | Jelle Zijlstra

submited by
Style Pass
2024-11-07 09:00:03

A common complaint about the Python type system is that it is too verbose and requires too many imports. There are many concrete ideas that come up from time to time for making the syntax more concise, but these tend to run into practical problems. This document is intended to list those ideas with the problems associated with them.

The problems listed here aren’t necessarily fatal to each idea. Some of them may be minor enough that the increase in concision is worth it. Others could be worked around with a tweak to the idea. If you feel that any of these ideas is worthwhile and you have the time and energy to drive a language change, feel free to create a PEP or open a discussion on https://discuss.python.org to move it forward.

Before going over ideas that probably won’t fly, it’s worth reminding ourselves of the improvements we’ve already made over the last decade of typed Python development:

As a bonus, this also allows using keys that are not valid identifiers, like the existing call-based syntax for creating a TypedDict.

Leave a Comment