Using mypy with an existing codebase
This section explains how to get started using mypy with an existing,significant codebase that has little or no type annotations. If you area beginner, you can skip this section.
These steps will get you started with mypy on an existing codebase:
- Start small – get a clean mypy build for some files, with fewannotations
- Write a mypy runner script to ensure consistent results
- Run mypy in Continuous Integration to prevent type errors
- Gradually annotate commonly imported modules
- Write annotations as you modify existing code and write new code
- Use MonkeyType or PyAnnotate to automatically annotate legacy code
We discuss all of these points in some detail below, and a few optionalfollow-up steps.