Mypy on Twitter is @mypyproject

Follow @mypyproject on Twitter

Why mypy?
Compile-time type checking
Static typing makes it easier to find bugs with less debugging.
Easier maintenance
Type declarations act as machine-checked documentation. Static typing makes your code easier to understand and easier to modify without introducing bugs.
Grow your programs from dynamic to static typing
You can develop programs with dynamic typing and add static typing after your code has matured, or migrate existing Python code to static typing.


Mypy is an experimental optional static type checker for Python that aims to combine the benefits of dynamic (or "duck") typing and static typing. Mypy combines the expressive power and convenience of Python with a powerful type system and compile-time type checking. Mypy programs are valid Python programs; run them using a standard Python VM with no translation, no compilation and with basically no runtime overhead.

Mypy is still in development. A significant subset of Python features is supported.

What's new

Mypy 0.2 released

5 Apr 2015: Mypy 0.2 was released. It's focused on PEP 484 (Type Hinting) draft compatibility and more complete Python feature support. Blog post -Jukka

Mypy and the PEP 484 (type hinting) draft

17 Jan 2015: Read my blog post about PEP 484 (Type Hinting) draft, which proposes adding a standard type annotation syntax strongly inspired by mypy to the upcoming Python 3.5 release. -Jukka

Older news

Seamless dynamic and static typing

From Python...
def fib(n):
    a, b = 0, 1
    while a < n:
        yield a
        a, b = b, a+b statically typed Python
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.

Python syntax

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.

Powerful type system

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.

Access to Python libs

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.

Learn more