[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

Mypy 0.760 Released

We’ve just uploaded mypy 0.760 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.

Type Signature Suggestions for Tools

Normally mypy only infers the types of variables, and you have to explicitly annotate functions. Mypy daemon can now generate a suggestion for a function or method signature using static analysis through dmypy suggest. This is a low-level feature that can be used by other tools and editor integrations to make it easier to annotate existing code. See the documentation for more information.

Type Inference Improvements

Mypy type inference got a few minor improvements. Mypy can now infer a variable with a collection type from two assignments:

    items = []  # No type annotation needed
    if check():
        items = [2, 3]

Previously mypy required a type annotation for items. Mypy can also more often infer an OrderedDict type:

    from collections import OrderedDict

    data = OrderedDict()  # No type annotation needed
    data['key'] = 4

Mypy can infer the type of an attribute in more cases when it’s first initialized through self.x:

    class Counts:
        def __init__(self, n: int) -> None:
            self.counts = {}  # Type inferred from initialization
            for i in range(n):
                self.counts[i] = 0

Fixes to Regressions

Breaking Changes

Other Notable Improvements and Bug Fixes

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:

Additional thanks to all contributors to typeshed: