Wednesday 10 May 2023

Mypy 1.3 Released

We’ve just uploaded mypy 1.3 to the Python Package Index (PyPI). Mypy is a static type checker for Python. This release includes new features, performance improvements and bug fixes. 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.

Performance Improvements

  • Improve performance of union subtyping (Shantanu, PR 15104)
  • Add negative subtype caches (Ivan Levkivskyi, PR 14884)

Stub Tooling Improvements

  • Stubtest: Check that the stub is abstract if the runtime is, even when the stub is an overloaded method (Alex Waygood, PR 14955)
  • Stubtest: Verify stub methods or properties are decorated with @final if they are decorated with @final at runtime (Alex Waygood, PR 14951)
  • Stubtest: Fix stubtest false positives with TypedDicts at runtime (Alex Waygood, PR 14984)
  • Stubgen: Support @functools.cached_property (Nikita Sobolev, PR 14981)
  • Improvements to stubgenc (Chad Dombrova, PR 14564)

Improvements to attrs

  • Add support for converters with TypeVars on generic attrs classes (Chad Dombrova, PR 14908)
  • Fix attrs.evolve on bound TypeVar (Ilya Konstantinov, PR 15022)

Documentation Updates

  • Improve async documentation (Shantanu, PR 14973)
  • Improvements to cheat sheet (Shantanu, PR 14972)
  • Add documentation for bytes formatting error code (Shantanu, PR 14971)
  • Convert insecure links to use HTTPS (Marti Raudsepp, PR 14974)
  • Also mention overloads in async iterator documentation (Shantanu, PR 14998)
  • stubtest: Improve allowlist documentation (Shantanu, PR 15008)
  • Clarify "Using types... but not at runtime" (Jon Shea, PR 15029)
  • Fix alignment of cheat sheet example (Ondřej Cvacho, PR 15039)
  • Fix error for callback protocol matching against callable type object (Shantanu, PR 15042)

Error Reporting Improvements

  • Improve bytes formatting error (Shantanu, PR 14959)

Mypyc Improvements

  • Fix unions of bools and ints (Tomer Chachamu, PR 15066)

Other Fixes and Improvements

  • Fix narrowing union types that include Self with isinstance (Christoph Tyralla, PR 14923)
  • Allow objects matching SupportsKeysAndGetItem to be unpacked (Bryan Forbes, PR 14990)
  • Check type guard validity for staticmethods (EXPLOSION, PR 14953)
  • Fix sys.platform when cross-compiling with emscripten (Ethan Smith, PR 14888)

Typeshed Updates

Typeshed is now modular and distributed as separate PyPI packages for everything except the standard library stubs. Please see git log for full list of typeshed changes.

Acknowledgements

Thanks to all mypy contributors who contributed to this release:

  • Alex Waygood
  • Amin Alaee
  • Bryan Forbes
  • Chad Dombrova
  • Charlie Denton
  • Christoph Tyralla
  • dosisod
  • Ethan Smith
  • EXPLOSION
  • Ilya Konstantinov
  • Ivan Levkivskyi
  • Jon Shea
  • Jukka Lehtosalo
  • KotlinIsland
  • Marti Raudsepp
  • Nikita Sobolev
  • Ondřej Cvacho
  • Shantanu
  • sobolevn
  • Tomer Chachamu
  • Yaroslav Halchenko