You may have heard that TypeScript has been taking the web development space by storm in the last few years, bringing to it static types. I believe the same thing is starting to happen in the world of Python, where type checkers like mypy, Pyre, and Pyright are increasingly used, at least where Python is used by companies to write large systems.
For the last several releases of Python, there have been an increasing number of type checking features added to each release by various PEPs:
typing
module are needed:
list[T]
, dict[K, V]
, etc in place of List[T]
and Dict[K, V]
.typing
module are needed:
X | Y
(PEP 604)
X | None
X?
(PEP 645)TypeForm
(planned)The traffic on typing-sig, the mailing list where most major new typing features are proposed and designed, has also been seeing increasing traffic year over year.1
I personally have found type checking to be very useful when working on large Python applications2. It helps me find numerous small errors that are introduced during regular development. Sure, most of these errors would be caught by the automated tests that I write for each new feature anyway, but the type checker can find a whole bunch of errors all at once without even running the program, which decreases cycle times when adding new features:
Without type checking I tend to:
But with type checking I can:
I appreciate this increased productivity that type checking gives me when working on large programs. And I hope that more Python users try type checking for themselves, especially as Python gains an increasing number of related features in recent releases. It’s an exciting time to be a Python developer!
Increasing traffic on typing-sig is reflected in an increasing number of discussions year-over-year. In 2019 there were 63 discussions. In 2020 there were 113 discussions (79% increase). And 2021 is just beginning.↩
I personally use type checking in a large Django web application that I work on.↩