Python Type Checking with ty
ty is an extremely fast Python type checker from Astral (makers of Ruff).
Quick Start
# Run type checker (no install needed)
uvx ty check
# Check specific files
uvx ty check src/ tests/
Installation (Optional)
# Install globally
uv tool install ty@latest
# Update
uv tool upgrade ty
Common Tasks
# Watch mode - auto-recheck on file changes
ty check --watch
# Target specific Python version
ty check --python-version 3.11
# Concise output
ty check --format concise
# Exclude test files
ty check --exclude "**/test_*.py"
Configuration File
Create ty.toml in project root (auto-discovered):
python-version = "3.11"
exclude = ["**/test_*.py", "**/__pycache__/**"]
format = "concise"
CI/CD
# Strict CI check
ty check --error all --error-on-warning --no-progress
Exit codes: 0 = success, 1 = errors found, 2 = internal error
Advanced Options
Severity Control
ty check --error all # All issues as errors
ty check --warn typing # Typing issues as warnings
ty check --ignore unused # Ignore unused imports
Environment Targeting
ty check --python /path/to/python # Specific interpreter
ty check --venv /path/to/venv # Target virtualenv
ty check --python-platform linux # Cross-platform check
ty check --extra-search-path ./stubs/
Output Formats
ty check --format full # Detailed (default)
ty check --format concise # Compact
ty check --format github # GitHub Actions annotations
ty check --format gitlab # GitLab CI format
ty check --color never # No colors
ty check --no-progress # Hide progress bar
ty check -v # Verbose
ty check -q # Quiet
Other Commands
ty server # Start LSP server
ty version # Show version
ty generate-shell-completion zsh # Shell completions
Scan to join WeChat group