
auto-type-annotate
https://github.com/getsentry/auto-type-annotate- Category
- Developer Tools
- Rank
- No. 1589Tools index
Previous survey · No. 1597 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- getsentry
- GitHub
- 197 stars
- Latest release
- 1.1.2
- Date
About
Automatically add type annotations to untyped Python code — run once to migrate a legacy codebase to typed.
What it does
It scans Python syntax for incomplete function signatures, asks mypy’s running daemon to infer types, then edits source text in place. It preserves existing annotations, adds required imports, converts older typing forms to modern syntax, and declines suggestions containing Any.
Why it's ranked here
This is a focused migration aid with unusually cautious rewrite behavior. It builds on a codebase’s existing mypy analysis instead of guessing alone, preserves annotations already present, and has integration tests for real daemon-driven edits. Its strict readiness requirements narrow the audience considerably.
What's good
The tool handles partially typed signatures instead of replacing them wholesale. It skips uncertain Any results, supports synchronous and asynchronous definitions, inserts imports after future imports and docstrings, understands multiple source roots, and normalizes inferred collection types into current Python syntax.
Tradeoffs
Your project must already pass mypy with untyped-body checking and local partial types enabled, while the mypy daemon remains running. That prerequisite may demand substantial cleanup before the tool helps. It ignores nested functions and abstract methods, silently skips failed suggestions, and writes selected files directly.
How to use it well
Use it for a Python 3.11 or newer project that already has disciplined mypy configuration and needs incremental signature coverage. Run it on selected files, inspect the resulting diff, and validate with mypy and tests. It does not perform the prerequisite type-checker cleanup or cover deliberately skipped functions.
Technical notes+
auto_type_annotate.py parses files with ast, collects eligible definitions through FindUntyped, invokes mypy.dmypy suggest with JSON output, and rewrites signatures through tokenize-rt. _replace preserves existing annotations and rejects types containing Any; _fixup_type adds cross-module imports and runs pyupgrade in a temporary file with Python 3.10-plus syntax conversion. setup.cfg defines the console entry point, Python requirement, and dependencies. tests/auto_type_annotate_test.py covers path mapping, discovery rules, imports, partial annotations, Any handling, datetime behavior, and daemon-backed integration. tox.ini runs pytest with coverage, while .github/workflows/main.yml tests Python 3.11 and 3.13 on Ubuntu and builds distribution artifacts.
Observed
- License
- Apache License 2.0
- Primary language
- Python
- Installation
- Published package installable with pip as auto-type-annotate
- Interface
- Command-line interface accepting one or more Python files and optional application roots
- Python support
- Requires Python 3.11 or newer and declares CPython support
- Packaging
- Setuptools package with mypy, pyupgrade, and tokenize-rt runtime dependencies
- Tests
- Repository includes unit and daemon-backed integration tests
Read from README.md, setup.py, setup.cfg, auto_type_annotate.py, tests/auto_type_annotate_test.py, LICENSE, tox.ini, .craft.yml, requirements-dev.txt, .pre-commit-config.yaml, scripts/bump-version.sh, .github/workflows/main.yml, .github/workflows/release.yml.
What it can do
Add type annotations to untyped Python functions
Python code with untyped function definitions → Python code with type-annotated function parameters and return types
Infer variable types in Python code
Python code with untyped variables → Python code with type annotations for variables
Convert legacy Python codebase to typed code
Entire Python project or codebase without type annotations → Type-annotated Python codebase
Analyze Python code to determine appropriate type hints
Python source code files → Type annotations based on code analysis
Migrate untyped Python methods to typed methods
Python classes with untyped methods → Python classes with type-annotated methods
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.