MonkeyType
Generating type annotations from sampled production types
Decision gist · record as of 2026-08-14
Yes, if you need to add type annotations to existing untyped Python code and are willing to review and refine the generated hints. The tool is stable (Production/Stable status) and has low install friction, but the aging maintenance status means you should verify it works with your Python version and check for any open issues matching your use case before committing to it in a critical workflow.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or later.
- The tool modifies your source code in-place when using 'apply', so version control or backups are recommended before running it.
- Low install friction with only two runtime dependencies (mypy-extensions and libcst).
License · maintenance · safety
BSD (permissive) — BSD license is permissive, allowing commercial and private use with minimal restrictions beyond attribution and liability disclaimers.
last release 2023-03-20 (1243 days) · last repo commit 2026-02-11 · 5,000 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 356,424 downloads/mo, #7,282 on PyPI
Alternatives
Verify before relying
pip install MonkeyType
# Run your script under MonkeyType to collect types
monkeytype run myscript.py
# Generate stub file or apply annotations
monkeytype stub some.module
monkeytype apply some.module- Whether the tool handles all Python language features equally well or has known gaps in type inference accuracy
- Performance impact when running production code under sys.setprofile instrumentation
- How well generated annotations handle polymorphic functions or complex generic types beyond the documented examples
What it is and what it does
MonkeyType is a runtime type collection and annotation tool that hooks into Python's function call mechanism to observe the actual types flowing through your code, then uses that data to generate type annotations. It works by running your code under sys.setprofile instrumentation, recording argument and return types into a SQLite database, and then either outputting stub files or modifying your source code directly to add the inferred annotations.
The tool is designed as a first-pass annotation generator: it produces concrete type hints based on what it observes at runtime, which may be narrower than the full capability of your functions. For example, a function that works with any numeric type will be annotated with the specific type it saw during execution. The generated annotations are meant to be reviewed and refined by a developer, not used blindly.
Use it for
- Quickly add type annotations to an existing untyped codebase by running your test suite or representative workload under MonkeyType
- Generate stub files for modules to enable static type checking without modifying the original source
- Bootstrap type safety in legacy Python code where manual annotation would be time-consuming
- Identify type inconsistencies by comparing inferred types across different execution paths or test cases
- Support Python 3.7+ codebases that need gradual typing adoption with minimal upfront effort
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to add type annotations to existing untyped Python code and are willing to review and refine the generated hints.
The tool is stable (Production/Stable status) and has low install friction, but the aging maintenance status means you should verify it works with your Python version and check for any open issues matching your use case before committing to it in a critical workflow.
Install
monkeytype on PyPI
Before you install
Low install friction with only two runtime dependencies (mypy-extensions and libcst). Maintenance status is aging—last release was in March 2023—but the repository remains active and unarchived with 5000 stars.
Requires Python 3.7 or later. The tool modifies your source code in-place when using 'apply', so version control or backups are recommended before running it.
License in practice
BSD license is permissive, allowing commercial and private use with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install MonkeyType
# Run your script under MonkeyType to collect types
monkeytype run myscript.py
# Generate stub file or apply annotations
monkeytype stub some.module
monkeytype apply some.module
Verify before relying
- Whether the tool handles all Python language features equally well or has known gaps in type inference accuracy
- Performance impact when running production code under sys.setprofile instrumentation
- How well generated annotations handle polymorphic functions or complex generic types beyond the documented examples
Package facts
| License | BSD permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesmypy-extensionslibcst |
| Maintenance | Aging 1,243 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 356,424 / month, #7,282 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: MonkeyType-23.3.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “infer types from execution”
- MonkeyTypeMonkeyType collects runtime types of function arguments and return…
- autotypingAutomatically infers and adds type annotations to Python functions…
- cleancoCleanco strips legal suffixes (Ltd, Corp, LLC, etc.) from company…
Give your agent the search over MCP, or paste the wish link into any chat.
More Quality Assurance packages
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
Ruff is a Python linter and code formatter written in Rust that combines linting, formatting, and code fixing into a single tool, replacing Flake8, Black, isort, and related utilities.
Pexpect spawns and controls interactive console applications by sending input and matching output patterns, automating tasks that would otherwise require manual interaction.
Black reformats Python source code to a consistent style by parsing entire files and rewriting them according to an opinionated, deterministic set of rules, eliminating manual formatting decisions.
pytest-xdist distributes pytest tests across multiple CPU cores or machines to speed up test execution, with the simplest usage being `pytest -n auto` to spawn workers equal to available CPUs.
Install it if your test suite takes long enough that parallelization would save meaningful time.
Validates AWS CloudFormation templates in YAML or JSON format against resource provider schemas and best practices, checking property values and configuration correctness.
Install it if you work with CloudFormation templates.
See also autotyping · typing-inspection · typing-inspect · pytest-beartype-tests · sqlalchemy-stubs · targ · types-smorest · types-antlr4-python3-runtime · mozcrash · homeassistant-stubs