Loading...
Loading...
Guide for using ty, the extremely fast Python type checker and language server. Use this when type checking Python code or setting up type checking in Python projects.
npx skill4agent add astral-sh/claude-code-plugins ty[tool.ty]pyproject.tomlty.tomluv run ty ...uvx ty ...ty check # Check all files in current directory
ty check path/to/file.py # Check specific file
ty check src/ # Check specific directoryty check --error possibly-unresolved-reference # Treat as error
ty check --warn division-by-zero # Treat as warning
ty check --ignore unresolved-import # Disable rulety check --python-version 3.12 # Check against Python 3.12
ty check --python-platform linux # Target Linux platformpyproject.tomlty.toml# pyproject.toml
[tool.ty.environment]
python-version = "3.12"
[tool.ty.rules]
possibly-unresolved-reference = "warn"
division-by-zero = "error"
[tool.ty.src]
include = ["src/**/*.py"]
exclude = ["**/migrations/**"]
[tool.ty.terminal]
output-format = "full"
error-on-warning = false[[tool.ty.overrides]]
include = ["tests/**", "**/test_*.py"]
[tool.ty.overrides.rules]
possibly-unresolved-reference = "warn".py.pyimypy . → ty check
mypy --strict . → ty check --error-on-warning
mypy path/to/file.py → ty check path/to/file.pypyright . → ty check
pyright path/to/file.py → ty check path/to/file.pyty: ignoretype: ignore# Good: rule-specific ignore
x = undefined_var # ty: ignore[possibly-unresolved-reference]
# Bad: blanket ty ignore
x = undefined_var # ty: ignore
# Bad: tool agnostic blanket ignore
x = undefined_var # type: ignore