skillfed

autotyping

A tool for autoadding simple type annotations.

autotyping v24.9.0 73.7K downloads/30d#14,945 on PyPI288
Permissive license AGING released

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 autotyping

uv

uv add autotyping

poetry

poetry add autotyping

Installing 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

Development Status :: 3 - AlphaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development

Tags

automatic type annotationadd type hints to codeinfer function typestype annotation toolpython typing automationcodemod type inferencelibcst type annotation
type-hintscodemodpre-commit

More Software Development packages