Add type hints and check them with mypy
Usage description
Improve the quality of existing Python code by adding types without changing its behaviour.
Prompt text
The code is in {{project}} ({{stack}}).
Add type hints gradually:
1. Start with the core modules that depend least on others.
2. Use precise types (TypedDict, Protocol, Literal) instead of Any where possible.
3. Run mypy --strict on each module after changing it, and fix the errors without changing the behaviour.
4. Run the existing tests after each module.
5. Write a summary of the completed and remaining modules and any unresolved errors with their cause.
{{extra}}Required inputs
The project path and the Python version.
Expected outputs
Typed changes, a mypy report and the test results.
Suitable tools
Practical example
project = "an internal data processing library" of about 40 files without types.
We do not claim this prompt was tested on a particular model; results vary with the model and context, so always review the output.
