| name | py-ty |
| description | Run ty (Astral's Python type checker) on Python code. Use when writing, editing,
or reviewing Python code to catch type errors. Triggers on: writing Python files,
"type check", "run ty", "check types", or after editing .py files.
|
| allowed-tools | ["Bash","Read","Edit","Write","Glob","Grep"] |
ty — Python Type Checker (Astral)
Fast Python type checker written in Rust. 10-100x faster than mypy/Pyright.
Repo: https://github.com/astral-sh/ty
When to use
Run ty check after writing or editing Python code. Always type-check before
considering a Python task complete.
Installation
uv tool install ty@latest
Key commands
ty check
ty check src/
ty check --python-version 3.11
ty check --watch
ty check --output-format concise
ty check --error-on-warning
Configuration
In pyproject.toml:
[tool.ty]
python-version = "3.11"
[tool.ty.rules]
division-by-zero = "warn"
index-out-of-bounds = "error"
Or in ty.toml:
[rules]
empty-body = "error"
Workflow
- After writing/editing Python code, run
ty check on the affected files
- Fix any type errors found
- Re-run until clean
- If a rule is intentionally violated, suppress with
# type: ignore[rule-name]
Output formats
full (default), concise, github, gitlab, junit