Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

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

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Typing
  3. pyannotate

pyannotate

Apache-2.0Python

Automatically generates PEP-484 type annotations for Python code by analyzing runtime behavior.

GitHubGitHub
1.4k stars60 forks0 contributors

What is pyannotate?

PyAnnotate is a Python tool that automatically generates PEP-484 type annotations by analyzing function calls and return types observed during runtime execution. It solves the problem of manually adding type hints to large existing codebases by inferring types from actual program behavior and inserting appropriate annotations into source code.

Target Audience

Python developers working with large legacy codebases who want to add type annotations efficiently, and teams adopting static type checking with mypy who need to annotate existing functions.

Value Proposition

Developers choose PyAnnotate because it dramatically reduces the manual effort required to add type annotations by automatically inferring types from runtime behavior, supports both Python 2 and 3 annotation styles, and integrates seamlessly with existing test suites.

Overview

Auto-generate PEP-484 annotations

Use Cases

Best For

  • Adding type annotations to large legacy Python codebases
  • Accelerating adoption of mypy static type checking in existing projects
  • Generating initial type hints for unannotated Python libraries
  • Reducing manual annotation work during Python 2 to Python 3 migrations
  • Inferring complex type relationships from actual runtime behavior
  • Integrating type annotation generation into existing pytest test suites

Not Ideal For

  • Projects that cannot execute code for type collection due to security or environment constraints
  • Codebases with highly dynamic or polymorphic types not fully exercised in test suites
  • Teams expecting fully accurate annotations without any post-generation manual adjustment

Pros & Cons

Pros

Runtime Type Inference

Infers types from actual runtime behavior during test execution, as implemented in the collect_types module for observing function calls.

Automatic Annotation Insertion

Generates and inserts PEP-484 annotations directly into source files based on collected JSON data, reducing manual effort.

Flexible Output Formats

Supports both Python 2-style type comments and Python 3-style inline annotations with the --py3 flag, aiding migration.

Test Integration

Easily integrates with pytest through configuration files like example_conftest.py, allowing seamless type collection during test runs.

Cons

Dependence on Test Coverage

Type inference relies on runtime data from tests; incomplete test suites can lead to missing or inaccurate annotations.

Manual Refinement Needed

The README admits that generated annotations often require tweaking to satisfy mypy, adding overhead after automation.

Legacy Architecture and Docs

The TO DO section highlights needs for better documentation and refactoring, which can hinder usability and maintenance.

Frequently Asked Questions

Quick Stats

Stars1,443
Forks60
Contributors0
Open Issues28
Last commit19 days ago
CreatedSince 2017

Tags

#developer-tools#python#testing-integration#mypy#type-annotations#pep-484#code-generation#static-analysis

Built With

P
Python

Included in

Typing2.0k
Auto-fetched 1 day ago

Related Projects

pyre-checkpyre-check

Performant type-checking for python.

Stars7,171
Forks452
Last commit29 days ago
monkeytypemonkeytype

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

Stars5,002
Forks209
Last commit5 months ago
RightTyperRightTyper

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

Stars359
Forks7
Last commit2 months ago
autotypingautotyping

Automatically add simple type annotations to your code

Stars287
Forks23
Last commit10 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