A Python tool that automatically adds simple type annotations to code using heuristics and LibCST.
Autotyping is a Python tool that automatically adds simple type annotations to code by using heuristics to infer obvious types. It helps developers save time during refactoring by inserting annotations for functions that return None, scalar values, or parameters with literal defaults. The tool is designed to handle repetitive annotation tasks that are tedious to do manually.
Python developers who are refactoring or adding type hints to existing codebases, especially those working on large projects where manual annotation is time-consuming.
Developers choose Autotyping because it automates the most straightforward type annotation tasks with reliable heuristics, integrates seamlessly via CLI, pre-commit hooks, or LibCST, and reduces manual effort while encouraging better type safety.
Automatically add simple type annotations to your code
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Adds -> None or scalar return types using heuristics for functions with no return or literal values, saving time on obvious cases as shown in the --none-return and --scalar-return flags.
Infers types from default values (e.g., True for bool) or common names like 'verbose', with flags like --bool-param and --guess-common-names reducing manual annotation effort.
Automatically annotates standard magic methods such as __str__ and __len__ with correct return types, handling tedious cases mentioned in the --annotate-magics flag.
Supports CLI, pre-commit hooks, and LibCST codemods, making it easy to fit into various workflows, as detailed in the Usage and pre-commit sections.
Can import type suggestions from pyanalyze via --pyanalyze-report, extending inference capabilities for more advanced cases beyond basic heuristics.
Does not model code flow, so it can miss implicit None returns or misinterpret complex logic, as admitted in the Limitations section, requiring manual type checker verification.
Focuses on simple types like bool and str; struggles with generics, unions, or custom types without manual configuration via flags like --annotate-optional, which needs user input.
Requires specifying multiple flags for different transformations, such as --safe or --aggressive, which can be overwhelming and error-prone for users new to the tool.