Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Typing
  3. infer-types

infer-types

MITPython1.0.0

A CLI tool that automatically adds type annotations to Python code using static analysis and heuristics.

GitHubGitHub
102 stars6 forks0 contributors

What is infer-types?

infer-types is a CLI tool that automatically adds type annotations to Python code using static analysis and heuristics. It helps developers annotate large, legacy codebases by inferring simple return types and reducing manual typing effort.

Target Audience

Python developers working on large or old codebases who need to add type annotations efficiently, and teams adopting type hints for better code maintainability.

Value Proposition

It provides a fully automated, static approach to type inference with smart heuristics and typeshed integration, significantly speeding up the annotation process compared to manual typing.

Overview

A CLI tool to automatically add type annotations into Python code. Must have tool for annotating existing code.

Use Cases

Best For

  • Adding type annotations to large, untyped Python codebases
  • Refactoring legacy Python code to include type hints
  • Automating simple type inference for functions with obvious return types
  • Integrating type checking into CI/CD pipelines for existing projects
  • Reducing manual effort when adopting Python's type system
  • Enforcing consistent type annotations across a project

Not Ideal For

  • Projects with highly dynamic or polymorphic code where static inference fails
  • Teams requiring 100% accurate type annotations without manual review
  • Codebases targeting Python versions below 3.10 without __future__ imports

Pros & Cons

Pros

Fully Automated Inference

Infers types 100% statically without executing code, allowing safe and fast annotation of large codebases with minimal effort, as highlighted in the README.

Smart Heuristic Rules

Uses multiple inference rules like function name patterns (e.g., 'is_' for bool) and control flow analysis, improving accuracy for common coding scenarios based on the documentation.

Typeshed Integration

Leverages the typeshed repository to find annotations for unannotated dependencies, reducing gaps in type coverage as mentioned in the features list.

Modern Syntax Output

Defaults to Python 3.10+ type syntax such as 'str | None', promoting cleaner code, though it requires adjustments for older versions.

Cons

Requires Post-Processing

Output can have duplicated or misplaced imports, necessitating additional tools like isort for cleanup, which adds steps to the workflow as noted in the usage instructions.

Limited to Simple Cases

The README admits it won't solve 100% of cases; complex logic or ambiguous types often need manual intervention, reducing effectiveness for advanced typing scenarios.

Python Version Constraints

Modern syntax output may break compatibility with Python versions below 3.10 unless __future__ annotations are added, introducing extra work for legacy projects.

Frequently Asked Questions

Quick Stats

Stars102
Forks6
Contributors0
Open Issues0
Last commit3 years ago
CreatedSince 2022

Tags

#developer-tools#code-formatter#typing#cli-tool#type-inference#annotations#python3#python#code-quality#mypy#type-annotations#refactoring#code-generation#static-analysis

Built With

P
Python

Included in

Typing2.0k
Auto-fetched 17 hours ago

Related Projects

pyre-checkpyre-check

Performant type-checking for python.

Stars7,171
Forks452
Last commit28 days ago
monkeytypemonkeytype

A Python library that generates static type annotations by collecting runtime types

Stars5,002
Forks209
Last commit5 months ago
pyannotatepyannotate

Auto-generate PEP-484 annotations

Stars1,443
Forks60
Last commit18 days ago
RightTyperRightTyper

A fast and efficient type assistant for Python, including tensor shape inference

Stars359
Forks7
Last commit2 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub