Friday 8 June 2018

Mypy 0.610 released

We’ve just uploaded mypy 0.610 to the Python Package Index (PyPI). Mypy is an optional static type checker for Python. This release includes new features, bug fixes and library stub (typeshed) updates. You can install it as follows:
    python3 -m pip install -U mypy
You can read the documentation for this release on ReadTheDocs.

New Features

Add a dmypy run command that starts/restarts the mypy daemon as needed

The 0.600 release added support for a mypy daemon (in beta) which can speed up mypy runtimes by a large factor, especially when performing incremental builds where only a few files have changed. To avoid requiring projects to write scripting around dmypy start/dmypy check/dmypy status, this release adds a dmypy run command that checks files while automatically managing the lifecycle of the daemon. A set of files (or directories) can be checked with dmypy run -- <flags> <files>. See the documentation for more details. As a simple example, the way we run dmypy on mypy itself is: dmypy run -- ``--ignore-imports=error --config-file=mypy_self_check.ini mypy/

Make async function return type more specific

The type of the object returned by calling an async function used to be Awaitable; it’s changed to Coroutine since such objects support calling send() and throw() on them (André Caron, PR 5052)

Other Improvements

  • Allow wildcards instead of configuration section names again (PR 5120)
  • Store the daemon’s socket in /tmp instead of the current directory (Ming-Yuan Jian, PR 5003)
  • Support types as converters and factory= in attrs plugin (David Euresti, PR 4917, PR 5005)
  • Use .dmypy.json instead of dmypy.json as the daemon run file (PR 5036)
  • Improve error messages for invalid tuple types (MentalMegalodon, PR 5042)
  • Make conditional expressions use Union instead of join when the result type is a Union (MentalMegalodon, PR 5041, PR 5095)
  • Add a reveal_locals() expression that displays the types of all local variables (Anton Ian Sipos, PR 3425)
  • Allow raise E when E has the type Type[Exn] (bwo, PR 4918)
  • Allow specifying multiple shadow files (Gareth T, PR 5023)
  • Relax overload checks to allow return types to be regular subtypes (Michael Lee, PR 5064)
  • Remove "builtins." from output for overloads and builtins.None (Jelle Zijlstra, PR 5073)
  • Allow __getattr__ in nested scopes (Jelle Zijlstra, PR 4958)
  • Support module-level __getattr__ outside of stubs (PEP 562) (Jelle Zijlstra, PR 4958)
  • Improve "Name already defined" error message (Sid Kapur, PR 5067)

Notable Bugs Fixed

  • Fix false positives caused by differing function parameter names in certain circumstances (Michael Lee, PR 4920)
  • Fix a number of daemon bugs (PR 4988, PR 4989, PR 4993, PR 4994, PR 5065, PR 5091)
  • Fix a crash that one of those earlier fixes caused (Nate White, PR 5126)
  • Support protocols in daemon mode (PR 4790)
  • Fix access to operators on metaclass through a type variable (Elazer Gershuni, PR 5009)
  • Fix descriptor/Union interactions (PR 5039)
  • Fix a crash bug caused by bogus symbol table nodes (PR 5094)
  • Fix crash when checking async generator return type (PR 5123)
  • Write indirect dependencies into the cache even when not in incremental mode (PR 5123)

Internal Improvements

  • Substantial test suite cleanups (Elazar Gershuni, PR 5011, PR 5041, PR 5076, PR 5075, PR 5087)
  • Use a shared incremental cache for pythoneval tests (Ethan Smith, PR 5114)
  • Fix testcmdline.py when run with pytest -n0 (PR 5113)

Documentation Improvements

  • Wide-ranging documentation improvements (PR 5043, PR 5053)
  • Reorganize the documentation into sections (Michael Lee, PR 5104)
  • Add mention of --check-untyped-defs option to docs (Tony E Lewis, PR 4996)
  • Clarify that checking Python 2 is fully supported (Mitchel Humpherys, PR 5029)

Acknowledgments

First of all, we’d like to thank our employer, Dropbox, for funding the mypy core team. Thanks to all mypy contributors who contributed to this release:
  • André Caron
  • Anton Ian Sipos
  • bwo
  • Daniel Li
  • David Euresti
  • Elazar Gershuni
  • Emil Hessman
  • Ethan Smith
  • Gareth T
  • Jelle Zijlstra
  • MentalMegalodon
  • Michael Lee
  • Mikel Solabarrieta
  • Ming-Yuan Jian
  • Mitchel Humpherys
  • Nate White
  • Sid Kapur
  • Tony E Lewis
Additional thanks to all contributors to typeshed:
  • Alex Vandiver
  • Andrew Gaul
  • Andrew Svetlov
  • Daniel Li
  • Danny Weinberg
  • David Euresti
  • Dmitry Figol
  • Dominik Gabi
  • Emil Hessman
  • Ethan Smith
  • Ilya Konstantinov
  • Jakub Nabaglo
  • Jasper Spaans
  • Jelle Zijlstra
  • Katelyn Gigante
  • Martijn Pieters
  • Michael Lee
  • Omar Sandoval
  • Phillip Schanely
  • Salvo 'LtWorf' Tomaselli
  • Sebastian Rittau
  • Semyon Proshev
  • Stanislav Syekirin
  • Thomas Schaper
  • Zabolekar
  • Zac Hatfield-Dodds
— Michael J. Sullivan, on behalf of the mypy team