Automatically generates PEP-484 type annotations for Python code by analyzing runtime behavior.
PyAnnotate is a Python tool that automatically generates PEP-484 type annotations by analyzing function calls and return types observed during runtime execution. It solves the problem of manually adding type hints to large existing codebases by inferring types from actual program behavior and inserting appropriate annotations into source code.
Python developers working with large legacy codebases who want to add type annotations efficiently, and teams adopting static type checking with mypy who need to annotate existing functions.
Developers choose PyAnnotate because it dramatically reduces the manual effort required to add type annotations by automatically inferring types from runtime behavior, supports both Python 2 and 3 annotation styles, and integrates seamlessly with existing test suites.
Auto-generate PEP-484 annotations
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Infers types from actual runtime behavior during test execution, as implemented in the collect_types module for observing function calls.
Generates and inserts PEP-484 annotations directly into source files based on collected JSON data, reducing manual effort.
Supports both Python 2-style type comments and Python 3-style inline annotations with the --py3 flag, aiding migration.
Easily integrates with pytest through configuration files like example_conftest.py, allowing seamless type collection during test runs.
Type inference relies on runtime data from tests; incomplete test suites can lead to missing or inaccurate annotations.
The README admits that generated annotations often require tweaking to satisfy mypy, adding overhead after automation.
The TO DO section highlights needs for better documentation and refactoring, which can hinder usability and maintenance.