5 ms·
Python didn't add static typing. It added arbitrary annotations of arguments and variables (admittedly, with the use case of type checking in mind). Mypy uses
by davesque 6y ago
Python didn't add static typing. It added arbitrary annotations of arguments and variables (admittedly, with the use case of type checking in mind). Mypy uses that for type annotations and checking. Here are the two main reasons I think it's useful:
* To the extent that it enables some static analysis on python code, it has often caught a number of errors I tend to make while writing code
* It serves as a light form of documentation that tends to stay more fresh because there's an automated way to check its consistency (run the type checker)
I don't expect that it will do as perfect a job as Rust or C++'s type system or even that it would be there for the same reasons. On the other hand, it's nice to just have more info about what the code is expected to do in the form of type annotations.
- dragonwriter 6y ago> Python didn’t add static typing. It added arbitrary annotations of arguments and variables (admittedly, with the use case of type checking in mind). Mypy uses that for type annotations and checking. Mypy started out as its own language with a Typescript-like relation to Python, evolved to being fully python compatible (using typing comments) after consultation with Guido (then-BDFL) and then python added annotations to support projects like mypy. It wasn’t just the that annotations were created and then mypy happened along to take advantage of them, supporting mypy specifically (without only supporting mypy) was a key motivation for annotations.