| Nov |
DEC |
Jan |
|
01 |
|
| 2019 |
2020 |
2021 |
About this capture
The Wayback Machine - http://web.archive.org/web/20201201031637/https://github.com/python/mypy
Skip to content
/;ref_cta:Sign up;ref_loc:header logged out">
Sign up
●
Features →
●Code review
●Project management
●Integrations
●Actions
●Packages
●Security
●Team management
●Hosting
●Mobile
●Customer stories →
●Security →
●
●
●
●Explore GitHub →
Learn & contribute
●Topics
●Collections
●Trending
●Learning Lab
●Open source guides
Connect with others
●Events
●Community forum
●GitHub Education
●GitHub Stars program
●
●
Plans →
●Compare plans
●Contact Sales
●Nonprofit →
●Education →
In this repository
All GitHub
↵
Jump to
↵
-
No suggested jump to results
{{ message }}
●
Sponsor python/mypy
●
Watch
203
●
Star
9.5k
●
Fork
1.5k
Optional static typing for Python 3 and 2 (PEP 484)
www.mypy-lang.org/
View license
9.5k
stars
1.5k
forks
Star
Watch
●
Code
●
Issues
1.4k
●
Pull requests
55
●
Actions
●
Projects
0
●
Wiki
●
Security
●
Insights
More
●
Code
●
Issues
●
Pull requests
●
Actions
●
Projects
●
Wiki
●
Security
●
Insights
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Sign up for free
24
branches
49
tags
Go to file
Code
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI.
Learn more.
●
Open with GitHub Desktop
●
Download ZIP
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio
If nothing happens, download the GitHub extension for Visual Studio and try again.
Latest commit
hauntsaninja
" class="link-gray-dark" href="/web/20201201031637/https://github.com/python/mypy/commit/88f76ee0e95674cc1ff4c723a86156823fb06291">Remove mypy_primer (#9769" class="link-gray-dark" href="/web/20201201031637/https://github.com/python/mypy/commit/88f76ee0e95674cc1ff4c723a86156823fb06291">)
88f76ee
Nov 30, 2020
Remove mypy_primer (#9769)
Co-authored-by: hauntsaninja <>
88f76ee
Git stats
●
9,271
commits
Files
Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
.github
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/88f76ee0e95674cc1ff4c723a86156823fb06291">Remove mypy_primer (#9769" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/88f76ee0e95674cc1ff4c723a86156823fb06291">)
Nov 30, 2020
docs
kinds_of_types: clearer sample bytestrings (#9764)
Nov 28, 2020
misc
Update wheel download script to use the correct file names for macOS (#…
Oct 8, 2020
mypy
Fix generic inheritance for attrs init methods (#9383)
Nov 28, 2020
mypyc
[mypyc] Generate names lazily when pretty-printing IR or generating C (…
Nov 29, 2020
scripts
[mypyc] Fix specifying opt level with scripts/mypyc (#8858)
May 20, 2020
test-data
Fix generic inheritance for attrs init methods (#9383)
Nov 28, 2020
.gitignore
ignore all vim temporary files (#9022)
Jun 26, 2020
.gitmodules
Use package_data to ship typeshed and xml files (#5517)
Aug 31, 2018
.travis.yml
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/83b30ee6a60bdd7c1070ce39d41c79d489183966">upgrade tox (#9746" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/83b30ee6a60bdd7c1070ce39d41c79d489183966">)
Nov 23, 2020
CONTRIBUTING.md
Clean up credits (#4626)
Feb 23, 2018
CREDITS
Add remaining core team emails to CREDITS (#4629)
Feb 24, 2018
LICENSE
Merge https://github.com/mypyc/mypyc into merge-mypyc
Aug 21, 2019
MANIFEST.in
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/f5f5485387c3ac9f4bbb56c036faee2a1abdaa70">MANIFEST.in: simplify and robust-ify (#9592" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/f5f5485387c3ac9f4bbb56c036faee2a1abdaa70">)
Oct 18, 2020
README.md
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/49a8c102a11d3ec8ffc48dc0a6d5409ed60767fd">README.md: remove mention of flake8-mypy (#9532" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/49a8c102a11d3ec8ffc48dc0a6d5409ed60767fd">)
Oct 5, 2020
ROADMAP.md
Update roadmap (#6378)
Feb 12, 2019
conftest.py
Merge https://github.com/mypyc/mypyc into merge-mypyc
Aug 21, 2019
mypy-requirements.txt
[mypyc] Add a mypyc_attr to support interpreted subclasses (#8004)
Nov 28, 2019
mypy_bootstrap.ini
Update mypyc to 0.0.1+dev.166151c2dc2c2eb13448d56e2dd31a9798557554 (#…
Aug 8, 2019
mypy_self_check.ini
mypy self check: add python_version = 3.5 (#8382)
Feb 7, 2020
pyproject.toml
enable isolated build via the PEP-517/518 spec (#6175)
Feb 26, 2019
pytest.ini
Use pytest Node.from_parent if available (#9263)
Aug 4, 2020
runtests.py
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/7f63b4961064ad736ad2647f7cee998631101424">runtests.py: list tests to run in typeshed CI (#9638" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/7f63b4961064ad736ad2647f7cee998631101424">)
Oct 27, 2020
setup.cfg
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/c90b405934cbf2142b8a575ddd89dbedf762106c">mypy: fix ci, use a newer flake8 and flake8-pyi, ignore a new error (#…
May 13, 2020
setup.py
setup.py: use find_packages (#9593)
Oct 18, 2020
test-requirements.txt
" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/6bd40b8ad4ac2cc76b27a14fc1fda9740b10ae17">test-requirements: bump minimum pytest needed (#9673" class="link-gray" href="/web/20201201031637/https://github.com/python/mypy/commit/6bd40b8ad4ac2cc76b27a14fc1fda9740b10ae17">)
Nov 4, 2020
tox.ini
stubtest: add tests (#8380)
Feb 13, 2020
README.md
Mypy: Optional Static Typing for Python


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:
●mypy tracker
for mypy issues
●typeshed tracker
for issues with specific modules
●typing tracker
for discussion of new type system features (PEP 484 changes) and
runtime bugs in the typing module
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.
Requirements
You need Python 3.5 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, macOS and Windows, packages are available at
https://www.python.org/getit/
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
You can also try mypy in an online playground (developed by
Yusuke Miyazaki).
IDE, Linter Integrations, and Pre-commit
Mypy can be integrated into popular IDEs:
●Vim:
●Using Syntastic: in ~/.vimrc add
let g:syntastic_python_checkers=['mypy']
●Using ALE: should be enabled by default when mypy is installed,
or can be explicitly enabled by adding let b:ale_linters = ['mypy']in~/vim/ftplugin/python.vim
●Emacs: using Flycheck and Flycheck-mypy
●Sublime Text: SublimeLinter-contrib-mypy
●Atom: linter-mypy
●PyCharm: mypy plugin (PyCharm integrates
its own implementation of PEP 484)
●VS Code: provides basic integration with mypy.
Mypy can also be set up as a pre-commit hook using pre-commit mirrors-mypy.
Web site and documentation
Documentation and additional information is available at the web site:
http://www.mypy-lang.org/
Or you can jump straight to the documentation:
https://mypy.readthedocs.io/
Troubleshooting
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
macOS, the script may be installed under /Library/Frameworks:
/Library/Frameworks/Python.framework/Versions/<version>/bin
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 inside your mypy repo,
your folders tree should be like mypy/mypy/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.
NOTE: Installing with sudo can be a security risk, please try with flag --user first.
$ python3 -m pip install --user -U .
Working with the git version of mypy
mypy contains a submodule, "typeshed". See https://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 mypy/typeshed
whenever you change branches, merge, rebase, or pull.
(It's possible to automate this: Search Google for "git hook update submodule")
Tests
The basic way to run tests:
$ pip3 install -r test-requirements.txt
$ python2 -m pip install -U typing
$ ./runtests.py
For more on the tests, such as how to write tests and how to control
which tests to run, see Test README.md.
Development status
Mypy is beta software, but it has already been used in production
for several years at Dropbox, and it has an extensive test suite.
See the roadmap if you are interested in plans for the
future.
Changelog
Follow mypy's updates on the blog: https://mypy-lang.blogspot.com/
Issue tracker
Please report any bugs and enhancement ideas using the mypy issue
tracker: https://github.com/python/mypy/issues
If you have any questions about using mypy or types, please ask
in the typing gitter instead: https://gitter.im/python/typing
Compiled version of mypy
We have built a compiled version of mypy using the mypyc
compiler for
mypy-annotated Python code. It is approximately 4 times faster than
interpreted mypy and is available (and the default) for 64-bit
Windows, macOS, and Linux.
To install an interpreted mypy instead, use:
$ python3 -m pip install --no-binary mypy -U mypy
If you wish to test out the compiled version of a development
version of mypy, you can directly install a binary from
https://github.com/mypyc/mypy_mypyc-wheels/releases/latest.
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.
License
Mypy is licensed under the terms of the MIT License (see the file
LICENSE).
About
Optional static typing for Python 3 and 2 (PEP 484)
www.mypy-lang.org/
Topics
python
types
typing
typechecker
linter
Resources
Readme
License
View license
49
tags
Sponsor this project
●
https://www.python.org/psf/donations/python-dev/
Learn more about GitHub Sponsors
+ 21,986
+ 404 contributors
Languages
●
Python
95.8%
●
C
3.0%
●
PLSQL
0.5%
●
C++
0.4%
●
XSLT
0.2%
●
Shell
0.1%
●© 2020 GitHub, Inc.
●Terms
●Privacy
●
●Security
●Status
●Help
●Contact GitHub
●Pricing
●API
●Training
●Blog
●About
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more