Wednesday, 3 June 2020

Mypy 0.780 Released

Mypy 0.780 Released

We’ve just uploaded mypy 0.780 to the Python Package Index (PyPI). Mypy is a 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 full documentation for this release on Read the Docs.

Following Imports in Mypy Daemon

You can now leave out the --follow-imports option when running dmypy, and mypy daemon will follow imports, similar to a non-daemon mypy run:

    dmypy run -- prog.py pkg/*.py

Previously mypy daemon did not support this, and it was necessary to use --follow-imports and explicitly mention all files to check on the command line. (Following imports in mypy daemon is an experimental feature.)

See the docs about following import in mypy.

Miscellaneous New Features

  • Support environment variable interpolation for junit_xml configuration key (Mattwmaster58, PR 8479)
  • Add no_site_packages config file setting (davidzwa, PR 8524)
  • Allow .mypy.ini (with a dot prefix) as an alternative name to mypy.ini (dosisod, PR 8515)
  • Disallow unpacking of strings in multiple assignment, as this is usually a bug (Abtin, PR 8589)
  • Allow type aliases in a runtime (non-type) context (PR 8779)
  • Add narrowing unions with bool literals via identity check (Steve Dignam, PR 8821)
  • Always allow to cast to Any without warnings (oda, PR 8544)
  • Suggest solutions for a typo in a key of a TypedDict (Felicián Németh, PR 8483)
  • Provide more context about why incompatible with supertype is an error (Chetan Khanna, PR 8866)

Other Notable Improvements and Bug Fixes

  • Fix handling dependencies to __call__ in mypy daemon (PR 8494)
  • Various improvements to stubtest (PR 8502, PR 8886) (Shantanu)
  • Fix invalid type causing named tuple errors reported in wrong files (PR 8549)
  • Clarify documentation of Liskov substitution principle (PR 8563)
  • Fix type inference with lambda that returns None (PR 8562)
  • Fix incremental crash bug caused by NewType in functions (PR 8607)
  • Fix indexed assignment check when TypedDict is used as upper bound (Xuanda Yang, PR 8621)
  • Improve error message for bad indexed assignment (pando, PR 8641)
  • Fix crash when the same file is processed under multiple names (PR 8644)
  • Fix parser when using Python 3.9 (PR 8716)
  • Accept dict() as an empty dictionary in a TypedDict context (PR 8749)
  • Fix incorrect coroutine return type for nested function (Jens Widell, PR 8741)
  • Reject bytes literal as a TypedDict key (PR 8782)
  • Allow attrs keyword-only arguments at any position (Markus Schmaus, PR 8803)
  • Detect duplicate keys in call-based TypedDict definitions (PR 8849)
  • Look at arguments when generating constraints for an overload (PR 8845)
  • Fix potential wrong-file error message for unsupported types (PR 8854)

Typeshed Updates

Many small improvements were made to typeshed — too many to list. Browse the typeshed commit log here.

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:

  • Abtin
  • Brad Solomon
  • Chetan Khanna
  • Claudio Jolowicz
  • davidzwa
  • Diego Elio Pettenò
  • dosisod
  • Ethan Smith
  • Felicián Németh
  • Jelle Zijlstra
  • Jens Widell
  • Joy Bhalla
  • LiuYuhui
  • Markus Schmaus
  • Marten Kenbeek
  • Mattwmaster58
  • Max R
  • oda
  • pando
  • PattenR
  • prostomarkeloff
  • Shantanu
  • Steve Dignam
  • Timofey Kukushkin
  • Ville Skyttä
  • Xuanda Yang

Additional thanks to all contributors to typeshed:

  • Alex McGrath Kraak
  • Alexandre Yang
  • Andrew
  • Andrew Svetlov
  • Anis
  • Anthony Sottile
  • Ben Leslie
  • Ben Motz
  • Benjamin Poirier
  • Brian Turek
  • Bruce Merry
  • Christopher Whelan
  • coiax
  • David Euresti
  • David T.H. Kao
  • Debjyoti Biswas
  • Denis Laxalde
  • Diego Elio Pettenò
  • dosisod
  • Ethan Smith
  • Florian Ludwig
  • Florimond Manca
  • Gal Ben David
  • Graham Bleaney
  • Jakub Stasiak
  • Jan Verbeek
  • Jaromir Latal
  • Javier Honduvilla Coto
  • Jeff Hunter
  • Jelle Zijlstra
  • Jia Chen
  • Jocelyn Boullier
  • Joost Cassee
  • Julian Andres Klode
  • Julin S
  • karl ding
  • Katelyn Gigante
  • Kazushi Kitaya
  • Kjell Braden
  • Lars
  • Lawrence
  • Luciano Ramalho
  • Mark Mendoza
  • Markus Wamser
  • Max R
  • Mickaël Schoentgen
  • Nguyễn Gia Phong
  • Nipunn Koorapati
  • Oleg Höfling
  • Paul Ganssle
  • Peter Pentchev
  • petsuter
  • PGijsbers
  • Philipp Hahn
  • Rahix
  • Ran Benita
  • Razzi Abuissa
  • Rebecca Chen
  • Rodrigo Castro
  • Rune Tynan
  • Sahith Nallapareddy
  • Sam Bull
  • Sebastian Rittau
  • Selim Belhaouane
  • Serhiy Storchaka
  • Shantanu
  • Steve Dignam
  • Tim Hatch
  • Vishal Kuo
  • Zhiming Wang