A typed superset of JavaScript that adds optional static types and compiles to readable, standards-based JavaScript.
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
Install mypy with pip
python3 -m pip install -U mypy - 2
Type-check your program
mypy PROGRAM
In collections
Topics
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
Run-time type checker for Python that validates PEP 484 annotations on functions, arbitrary objects, and local variables.
Pure-Python runtime type checker that enforces PEP type hints on functions, classes and variables with minimal overhead.
A protoc plugin that generates Python .pyi type stub files from Protocol Buffer definitions, with typed HasField, ClearField and gRPC stubs.
A fast Python type checker and language server, written in Rust, with IDE features like navigation, completion and semantic highlighting.
A Rust port of the TypeScript 7 compiler and language server, offered as a drop-in replacement for type checking and emit.