Repolode
python

python/mypy

A static type checker for Python that finds type errors in code with PEP 484 type hints without running it.

Stars
20,715
Forks
3,371
Open issues
3,232
Last commit
22 hours ago

What is it?

Mypy is a static type checker for Python. You add type hints (PEP 484) to your code, and mypy reports places where values or functions are used with incompatible types, catching many bugs before the program runs.

Typing is gradual: you can annotate a codebase incrementally and fall back to dynamic typing where static types are inconvenient. Type hints do not change how the program runs, so the regular Python interpreter can still execute code that mypy flags. The type system supports inference, generics, callable types, tuple and union types, and structural subtyping.

For large projects, mypy offers a daemon mode (dmypy) that provides fast incremental re-checks. Mypy integrates with editors such as VS Code, Vim, Emacs, and Sublime Text, and can run in pre-commit hooks. It is itself compiled with mypyc.

Key features

  • 01Checks type hints (PEP 484) and reports incompatible uses without running the code.
  • 02Supports type inference, generics, callable, tuple, and union types, and structural subtyping.
  • 03Allows gradual typing, so untyped code can coexist with annotated code.
  • 04Provides a daemon mode (dmypy) for fast incremental checks on large codebases.
  • 05Integrates with editors including VS Code, Vim, Emacs, and Sublime Text.

Use cases

  • Catching type-related bugs in Python projects before they reach production.
  • Adding type annotations gradually to an existing legacy Python codebase.
  • Enforcing type checks in CI or pre-commit hooks for team projects.

Quick start

  1. 1

    Install mypy with pip

    python3 -m pip install -U mypy
  2. 2

    Type-check your program

    mypy PROGRAM

In collections

Topics

#python#static-typing#type-checker#type-hints#linter#pep-484#typechecker#types#typing

FAQ

What is mypy?
A static type checker for Python that finds type errors in code with PEP 484 type hints without running it. Mypy is a static type checker for Python. You add type hints (PEP 484) to your code, and mypy reports places where values or functions are used with incompatible types, catching many bugs before the program runs.
Is mypy free to use? What license does it have?
mypy is open source under the Other license. Check the license terms before using it in commercial products.
Is mypy still maintained?
Actively maintained. The last commit to mypy was on Nov 6, 2026.
What can I use mypy for?
Catching type-related bugs in Python projects before they reach production. Adding type annotations gradually to an existing legacy Python codebase. Enforcing type checks in CI or pre-commit hooks for team projects.
How do I install mypy?
Install mypy with pip: python3 -m pip install -U mypy Type-check your program: mypy PROGRAM
Where can I get mypy?
The source code and installation instructions are on GitHub: https://github.com/python/mypy

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects