Mypy is still in development. A significant subset of Python features is supported.
Mypy and the PEP 484 (type hinting) draft
23 Nov 2014: We've been converting mypy documentation to reStructuredText/Sphinx and improving it in the process (thanks to Ryan Gonzalez for the bulk of the work!). The new docs are now public and hosted on readthedocs.org. The source code is available on GitHub. -Jukka
def fib(n): a, b = 0, 1 while a < n: yield a a, b = b, a+b
def fib(n: int) -> Iterator[int]: a, b = 0, 1 while a < n: yield a a, b = b, a+b
Migrate existing code to static typing, a function at a time. You can freely mix static and dynamic typing within a program, within a module or within an expression. No need to give up dynamic typing — use static typing when it makes sense. Often just adding function signatures gives you statically typed code. Mypy can infer the types of other variables.
Every mypy program is syntactically valid Python. Getting started is easy if you know Python. The aim is to support almost all Python language constructs in mypy.
Mypy has a powerful, modern type system with features such as bidirectional type inference, generics, function types, abstract base classes, multiple inheritance and tuple types.
You can access Python modules in mypy programs. Most commonly used libraries have statically typed interface definitions that allow the type checker to check code that uses the libraries.