Yesterday the Mypy team uploaded mypy 0.730 to the Python Package Index (PyPI). Mypy is a static type checker for Python. This release includes many features, bug fixes and library stub updates. You can install it as follows:
python3 -m pip install -U mypy
Python creator Guido van Rossum tweeted about this release, he says “mypy 0.720 released. New semantic analyzer is now the default! Also, --warn-unreachable flag, and many more fixes and updates.”
Some of the breaking changes in the Mypy 0.730 include:
If you call a function with an incompatible argument type, mypy now points the error message to the argument with the incompatible type. Previously, mypy pointed to the function being called, which could be confusing in multi-line calls.
Mypy 0.730 can now optionally display error codes. They are shown within square brackets after each error message:
prog.py:24: error: "str" has no attribute "trim" [attr-defined]
Enable error codes using --show-error-codes (or show_error_codes = True in a configuration file).
You can ignore only errors with specific error codes on a particular line by using a # type: ignore[code, ...] comment. This reduces the risk of ignoring unexpected, serious errors when using # type: ignore comments that ignore (almost) all possible errors on a line.
Mypy 0.730 now uses colored, more user-friendly output by default. You can use --no-color to disable colored output. You can use --no-error-summary to hide the summary line with the number of errors.
You can use --pretty to display each line which had errors and a caret that points to the location of the error on each line.
This release of Mypy 0.730 no longer includes the old semantic analyzer.
The --warn-unreachable option now behaves more correctly with “exception-swallowing” context managers. If a context manager is currently declared to return bool but it never swallows exceptions, you should annotate the return of __exit__ as Literal[False] instead of bool, or otherwise mypy may complain about missing return statements.
To know more about this release, read the full documentation on Read the Docs.
Łukasz Langa at PyLondinium19: “If Python stays synonymous with CPython for too long, we’ll be in big trouble”
Microsoft introduces Pyright, a static type checker for the Python language written in TypeScript
Python 3.8 alpha 2 is now available for testing