Optional static typing for Python 2 and 3 (PEP 484)
mkurnikov and ilevkivskyi Add arg_names attribute to FunctionContext and MethodContext (#5918)
This also adds `callable_arg_names` and `arg_kinds` for more tricky situations,
where plugins otherwise would have hard times.
Latest commit ed248c8 Dec 16, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Add plugin docs (#6057) Dec 13, 2018
extensions Bump the mypy_extensions version number to 0.5.0-dev (#5450) Aug 15, 2018
misc Implement a sqlite-based store for the cache (#6023) Dec 10, 2018
mypy Add arg_names attribute to FunctionContext and MethodContext (#5918) Dec 16, 2018
scripts Delete scripts/dmypy (#5984) Dec 1, 2018
test-data Add arg_names attribute to FunctionContext and MethodContext (#5918) Dec 16, 2018
tmp-test-dirs Allow testsuite to run in parallel Oct 11, 2015
.gitignore Remove runtests.py (#5274) Jul 18, 2018
.gitmodules Use package_data to ship typeshed and xml files (#5517) Aug 31, 2018
.travis.yml Trigger mypy_mypyc builds on pushes to release branches (#5997) Dec 4, 2018
CONTRIBUTING.md Clean up credits (#4626) Feb 23, 2018
CREDITS Add remaining core team emails to CREDITS (#4629) Feb 24, 2018
ISSUE_TEMPLATE.md Add a note about typeshed to the issue template (#4478) Jan 17, 2018
LICENSE Remove bundled lib-typing (#3337) May 29, 2017
MANIFEST.in Use package_data to ship typeshed and xml files (#5517) Aug 31, 2018
README.md Add a note about mypy_mypyc to the README (#5881) Nov 16, 2018
ROADMAP.md Remove outdated points from roadmap (#5196) Jun 11, 2018
appveyor.yml Use package_data to ship typeshed and xml files (#5517) Aug 31, 2018
build-requirements.txt Make typing and typed-ast external dependencies (#2452) Jan 6, 2017
conftest.py conftest.py: Fix lint May 23, 2017
mypy_bootstrap.ini More tweaks to support mypyc (#5513) Aug 28, 2018
mypy_self_check.ini More tweaks to support mypyc (#5513) Aug 28, 2018
pyproject.toml CI upgrades (Travis and AppVeyor) (#5417) Aug 4, 2018
pytest.ini support for PyCharm test debugging, and add tox environment setup (#5189 Jun 14, 2018
runtests.py Put daemon tests in the slow lane (#5995) Dec 3, 2018
setup.cfg Correct lint errors and silence W504 (#5830) Oct 24, 2018
setup.py Use multi-file mypyc compilation on windows (#6072) Dec 14, 2018
test-requirements.txt Add machinery for marking places we subvert the type system (#5467) Aug 15, 2018
tox.ini CI upgrades (Travis and AppVeyor) (#5417) Aug 4, 2018


mypy logo

Mypy: Optional Static Typing for Python

Build Status Chat at https://gitter.im/python/typing Checked with mypy

Got a question? Join us on Gitter!

We don't have a mailing list; but we are always happy to answer questions on gitter chat. If you are sure you've found a bug please search our issue trackers for a duplicate before filing a new issue:

What is mypy?

Mypy is an optional static type checker for Python. You can add type hints (PEP 484) to your Python programs, and use mypy to type check them statically. Find bugs in your programs without even running them!

You can mix dynamic and static typing in your programs. You can always fall back to dynamic typing when static typing is not convenient, such as for legacy code.

Here is a small example to whet your appetite (Python 3):

from typing import Iterator

def fib(n: int) -> Iterator[int]:
    a, b = 0, 1
    while a < n:
        yield a
        a, b = b, a + b

See the documentation for more examples.

For Python 2.7, the standard annotations are written as comments:

def is_palindrome(s):
    # type: (str) -> bool
    return s == s[::-1]

See the documentation for Python 2 support.

Mypy is in development; some features are missing and there are bugs. See 'Development status' below.


You need Python 3.4 or later to run mypy. You can have multiple Python versions (2.x and 3.x) installed on the same system without problems.

In Ubuntu, Mint and Debian you can install Python 3 like this:

$ sudo apt-get install python3 python3-pip

For other Linux flavors, OS X and Windows, packages are available at


Quick start

Mypy can be installed using pip:

$ python3 -m pip install -U mypy

If you want to run the latest version of the code, you can install from git:

$ python3 -m pip install -U git+git://github.com/python/mypy.git

Now, if Python on your system is configured properly (else see "Troubleshooting" below), you can type-check the statically typed parts of a program like this:

$ mypy PROGRAM

You can always use a Python interpreter to run your statically typed programs, even if they have type errors:

$ python3 PROGRAM

IDE & Linter Integrations

Mypy can be integrated into popular IDEs:

Mypy can also be integrated into Flake8 using flake8-mypy.

Web site and documentation

Documentation and additional information is available at the web site:


Or you can jump straight to the documentation:



Depending on your configuration, you may have to run pip like this:

$ python3 -m pip install -U mypy

This should automatically install the appropriate version of mypy's parser, typed-ast. If for some reason it does not, you can install it manually:

$ python3 -m pip install -U typed-ast

If the mypy command isn't found after installation: After python3 -m pip install, the mypy script and dependencies, including the typing module, will be installed to system-dependent locations. Sometimes the script directory will not be in PATH, and you have to add the target directory to PATH manually or create a symbolic link to the script. In particular, on Mac OS X, the script may be installed under /Library/Frameworks:


In Windows, the script is generally installed in \PythonNN\Scripts. So, type check a program like this (replace \Python34 with your Python installation path):

C:\>\Python34\python \Python34\Scripts\mypy PROGRAM

Working with virtualenv

If you are using virtualenv, make sure you are running a python3 environment. Installing via pip3 in a v2 environment will not configure the environment to run installed modules from the command line.

$ python3 -m pip install -U virtualenv
$ python3 -m virtualenv env

Quick start for contributing to mypy

If you want to contribute, first clone the mypy git repository:

$ git clone --recurse-submodules https://github.com/python/mypy.git

If you've already cloned the repo without --recurse-submodules, you need to pull in the typeshed repo as follows:

$ git submodule init
$ git submodule update

Either way you should now have a subdirectory typeshed containing a clone of the typeshed repo (https://github.com/python/typeshed).

From the mypy directory, use pip to install mypy:

$ cd mypy
$ python3 -m pip install -U .

Replace python3 with your Python 3 interpreter. You may have to do the above as root. For example, in Ubuntu:

$ sudo python3 -m pip install -U .

Now you can use the mypy program just as above. In case of trouble see "Troubleshooting" above.

Working with the git version of mypy

mypy contains a submodule, "typeshed". See http://github.com/python/typeshed. This submodule contains types for the Python standard library.

Due to the way git submodules work, you'll have to do

  git submodule update typeshed

whenever you change branches, merge, rebase, or pull.

(It's possible to automate this: Search Google for "git hook update submodule")


The basic way to run tests:

$ pip3 install -r test-requirements.txt
$ ./runtests.py

For more on the tests, see Test README.md

Development status

Mypy is alpha software, but it has already been used in production for well over a year at Dropbox, and it has an extensive test suite.

See the roadmap if you are interested in plans for the future.

Issue tracker

Please report any bugs and enhancement ideas using the mypy issue tracker:


Feel free to also ask questions on the tracker.


We have built an experimental compiled version of mypy using the mypyc compiler for mypy-annotated Python code. It is approximately 4 times faster than interpreted mypy.

If you wish to test out the compiled version of mypy, and are running OS X or Linux, you can directly install a binary from https://github.com/mypyc/mypy_mypyc-wheels/releases/latest.

Compiled mypy packages on PyPI are Coming Soon.

Help wanted

Any help in testing, development, documentation and other tasks is highly appreciated and useful to the project. There are tasks for contributors of all experience levels. If you're just getting started, ask on the gitter chat for ideas of good beginner issues.

For more details, see the file CONTRIBUTING.md.


Mypy is licensed under the terms of the MIT License (see the file LICENSE).