Thursday 9 June 2016

Mypy 0.4.2 Released

I just uploaded version 0.4.2 of mypy-lang to PyPI! This is a minor release that focuses on bug fixes.

The biggest change is the addition of Type[C]. You can now accurately describe the type of an argument whose type is itself a type or class. Given a class C, a function argument annotated with Type[C] can be a class object that's either C or a subclass of C. You can call C's class methods on that argument, and instantiate it using the constructor signature(s) supported by C. Combined with a type variable with C as an upper bound you can do even more powerful things. The Type operator must be imported from the typing module. It will be available starting Python 3.5.2. See the description in PEP 484.

Note: To use typing.Type[C], you need Python 3.5.2 (to be released shortly) or you can pip install the latest version of typing.

These are the other notable changes in this release:

  • Add reveal_type(expr) for displaying the static type of an expression.
  • Better IntEnum support.
  • Get the latest version of typing from python/typing repo (for Python 3.4 and earlier that don't include typing in stdlib).
  • When both foo.py* and foo/__init__.py* exist, prefer the latter.
  • Suppress error about untyped defs in typeshed stubs.
  • Fix use of property in a NamedTuple class.
  • Fix how the fast parser interprets string literals in Python 2.
  • Other bug fixes.
  • Typeshed stub updates.
  • Documentation updates, such as a type annotation cheat sheet.
  • Stop testing running mypy with Python 3.2. We’ll likely drop support for running mypy itself with 3.2 pretty soon, though you'll still be able to type check Python 3.2 code.

Acknowledgements

Thanks to all mypy contributors who contributed to this release:

  • Akshit Khurana
  • Andrew Sprenchynat
  • Babak
  • Jakub Stasiak
  • Jeffrey McLarty
  • Josh Soref
  • Justus Adam
  • Margaret Sy
  • Max Wittek
  • Peter McCormick
  • Ryan Gonzalez
  • Tarashish Mishra
  • Thiago
  • Tim Abbott
  • Thomas Ballinger
  • Valérian Rousset

Additional thanks to typeshed contributors:

  • beckjake
  • Dakkaron
  • David Euresti
  • David Shea
  • detlefla
  • Eklavya Sharma
  • Erin Haswell
  • Florian Bruhin
  • Jakub Stasiak
  • James Tatum
  • jukebox
  • Max Payton
  • Michael R. Crusoe
  • Oren Leaffer
  • Ran Benita
  • Thomas Grainger
  • Tim Abbott
  • Tim Simpson
  • Vadim Chugunov
  • Valérian Rousset
- Jukka (on behalf of the rest of the mypy team: Guido, David, Greg and Reid)