{"library":"monkeytype","title":"MonkeyType","description":"MonkeyType is a Python library that automatically generates type annotations from sampled production types. It uses Python's `sys.setprofile` hook to record the types of function arguments, return values, and yield values at runtime. Based on this collected data, it can generate stub files (`.pyi`) or apply draft type annotations directly to existing Python code. The current stable version is 23.3.0, with a history of regular updates focusing on Python version compatibility and annotation accuracy.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install monkeytype"],"cli":{"name":"monkeytype","version":"usage: monkeytype [-h] [--disable-type-rewriting] [--limit LIMIT] [--verbose]"}},"imports":["from monkeytype import trace","from monkeytype.config import Config"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\n\n# my_module.py\ndef add(a, b):\n    return a + b\n\ndef concatenate(s1, s2):\n    return s1 + s2\n\n# To run this module with MonkeyType tracing\nif __name__ == \"__main__\":\n    # Simulate usage to collect type traces\n    add(1, 2)\n    add(1.5, 2.5)\n    concatenate(\"hello\", \"world\")\n    concatenate([\"a\"], [\"b\", \"c\"])\n\n# --- Steps to run from your terminal ---\n# 1. Save the above code as 'my_module.py'.\n# 2. Run your module under MonkeyType to collect traces:\n#    $ monkeytype run my_module.py\n# 3. Generate a stub file (.pyi) from the collected traces:\n#    $ monkeytype stub my_module > my_module.pyi\n# 4. Or, apply type annotations directly to your source file (modifies in-place):\n#    $ monkeytype apply my_module\n#\n# Note: Traces are stored in a SQLite database (monkeytype.sqlite3) by default.","lang":"python","description":"The quickstart demonstrates the typical workflow: first, run your Python code with `monkeytype run` to collect runtime type traces. Then, use `monkeytype stub` to generate a `.pyi` stub file with annotations, or `monkeytype apply` to inject the annotations directly into your Python source file.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"23.3.0","pypi_latest":"23.3.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.6,"avg_import_s":0.09,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.08,"mem_mb":3.3,"disk_size":"32.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.6,"import_time_s":0.05,"mem_mb":3.3,"disk_size":"34M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.13,"mem_mb":3.6,"disk_size":"36.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.5,"import_time_s":0.12,"mem_mb":3.6,"disk_size":"38M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.11,"mem_mb":3.5,"disk_size":"27.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.5,"import_time_s":0.11,"mem_mb":3.5,"disk_size":"29M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.1,"mem_mb":3.9,"disk_size":"27.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.1,"mem_mb":3.7,"disk_size":"29M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.07,"mem_mb":3.1,"disk_size":"32.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"monkeytype","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0.06,"mem_mb":3.1,"disk_size":"34M"}]}}