autotyping
A tool for autoadding simple type annotations.
What it is and what it does
Autotyping is a command-line tool and libcst codemod that automatically adds type annotations to Python code where they are obvious from context. It uses heuristics to infer types from function bodies (e.g., functions with no return statement get `-> None`), parameter defaults (e.g., `flag=True` becomes `flag: bool`), and magic method signatures. It supports multiple invocation modes: direct CLI, pre-commit hooks, or as a libcst codemod.
The tool offers granular flags for different annotation strategies—`--none-return`, `--bool-param`, `--scalar-return`, and others—plus shortcut flags like `--safe` (conservative changes) and `--aggressive` (riskier inference). It can also integrate with pyanalyze's type suggestions. The documentation explicitly warns that heuristics may fail and that you should run a type checker afterward to verify correctness.
Use it for:
- Add `-> None` annotations to functions that don't return anything, eliminating tedious manual work.
- Annotate boolean, string, and numeric parameters based on their literal default values.
- Bulk-annotate magic methods like `__init__`, `__str__`, and `__len__` with their standard return types.
- Integrate into a pre-commit hook to enforce type annotations on every commit automatically.
- Use as a libcst codemod in a larger refactoring pipeline to seed a codebase with starter annotations.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically infers and adds type annotations to Python functions based on context clues like return statements, parameter defaults, and magic methods.
Yes, with conditions. Install if you want to reduce boilerplate type annotation work and are willing to verify the results with a type checker. The low install friction and permissive license make it a low-risk experiment. However, the 690-day gap since the last release suggests limited active maintenance; use it as a helper tool rather than a critical part of your workflow, and always validate its output.
Install
autotyping on PyPI
pip
pip install autotypinguv
uv add autotypingpoetry
poetry add autotypingInstalling autotyping
Before you install
Low friction: pure Python wheel with only two runtime dependencies (libcst and typing-extensions). Maintenance shows aging status—690 days since last release—but the repository remains active with recent commits and no archived status.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install autotyping
python -m autotyping /path/to/code --safe
# Or as a libcst codemod:
python -m libcst.tool codemod autotyping.AutotypeCommand /path/to/code
Requires Python 3.8 or later. Heuristic-based inference may produce incorrect annotations; always verify with a type checker afterward.
Verify before relying
- Whether the tool's heuristics work reliably on large codebases or edge cases beyond the documented limitations.
- How well the --pyanalyze-report integration works in practice with current pyanalyze versions.
- Performance characteristics when run on very large code repositories.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — libcst, typing-extensions |
| Maintenance | aging — 690 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,704/month — #14,945 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: autotyping-24.9.0-py3-none-any.whl
Keywords: annotations, typing
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
code-annotationsParses and summarizes code annotations…
permissive · top 15,000 on PyPI
MonkeyTypeMonkeyType collects runtime types of function…
permissive · top 15,000 on PyPI
types-sqlalchemy-utilsProvides type stubs for sqlalchemy-utils,…
copyleft · top 5,000 on PyPI
flake8-annotationsA Flake8 plugin that enforces PEP 3107-style…
permissive · top 15,000 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
types-smorestProvides type stubs for flask-smorest, enabling…
copyleft · top 5,000 on PyPI
flake8-annotations-complexityA flake8 plugin that flags type annotations…
permissive · top 15,000 on PyPI
types-decoratorProvides type stubs for the `decorator`…
permissive · top 5,000 on PyPI
types-pysaml2Provides type annotations (stubs) for the…
copyleft · top 15,000 on PyPI
libcstlibcst parses Python source code into a…
permissive · top 1,000 on PyPI