Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
collect_types
✓ from pyannotate_runtime import collect_types
✗ from pyannotate_tools.annotations import collect_types
This quickstart demonstrates collecting type data via pytest and then applying annotations to a Python file using pyannotate's tools.
# 1. Collect type information during tests with pytest
# Add to conftest.py:
# from pyannotate_tools.pytest_hooks import pytest_collect_types
# def pytest_configure(config):
# config.pluginmanager.register(pytest_collect_types())
# 2. Run tests: pytest --annotations-output annotate.json
# 3. Generate annotations in your source files:
import json
from pyannotate_tools.annotations import render_annotations
with open('annotate.json') as f:
annotations = json.load(f)
# 'code' is the path to your Python file
code = '/path/to/your/module.py'
with open(code) as f:
source = f.read()
try:
annotated = render_annotations(source, annotations, path=code)
if annotated != source:
with open(code, 'w') as f:
f.write(annotated)
print("Annotations applied to", code)
else:
print("No annotations to apply")
except Exception as e:
print("Error:", e)
Upgrade
Version history
1.2.0latest on PyPI · released Sep 16, 2019
Audit
Dependencies
pytestrequiredRequired for the pytest plugin to collect type info during test runs.
sixrequiredRequired for Python 2/3 compatibility.