mypy type-checks Python statically and can be adopted incrementally
Answer: You can install mypy using pip: python3 -m pip install mypy. Mypy requires Python 3.10 or later to run. After the install, run mypy program.py.
That command type-checks program.py and prints errors it finds. Mypy will type check your code statically. It checks for errors without ever running your code, just like a linter. You can still run the file with the Python interpreter if mypy reports errors.
The getting-started chapter introduces some core concepts of mypy, including function annotations, the typing module, and stub files. Existing unannotated code will most likely report little to no errors. That behavior is a feature, because it makes it easy to adopt mypy incrementally.
See also
Claims
- id: C1 claim: Mypy requires Python 3.10 or later to run. source: S1 evidence: "Mypy requires Python 3.10 or later to run."
- id: C2 claim: You can install mypy using pip. source: S2 evidence: "You can install mypy using pip:"
- id: C3 claim: mypy type-checks a file without running the code. source: S2 evidence: "it will check for errors without ever running your code, just"
- id: C4 claim: The getting-started chapter introduces function annotations and typing. source: S2 evidence: "including function"
Sources
- [S1] Getting started. mypy docs. https://mypy.readthedocs.io/en/stable/getting_started.html . License: MIT. Accessed 2026-11-16.
- [S2] Getting started (mypy source docs). python/mypy (GitHub). https://github.com/python/mypy/blob/master/docs/source/getting_started.rst . License: MIT. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: mypy docs, Getting started, MIT (https://raw.githubusercontent.com/python/mypy/master/LICENSE); python/mypy (GitHub), Getting started (mypy source docs), MIT (https://raw.githubusercontent.com/python/mypy/master/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: mypy docs, Getting started, MIT (https://raw.githubusercontent.com/python/mypy/master/LICENSE); python/mypy (GitHub), Getting started (mypy source docs), MIT (https://raw.githubusercontent.com/python/mypy/master/LICENSE).
Cite this
iinventedlight. 2026. "mypy type-checks Python statically and can be adopted incrementally." iinventedlight Library, iil:note:3jzsdypb, version of 2026-11-16. https://iinventedlight.com/library/notes/mypy-type-checker/. License: CC-BY-4.0.
@misc{iil_note_3jzsdypb,
author = {{iinventedlight}},
title = {{mypy type-checks Python statically and can be adopted incrementally}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/mypy-type-checker/},
note = {Permanent ID iil:note:3jzsdypb. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/mypy-type-checker.md.