| name | ty-0-0-51 |
| description | Run ty (Astral's Python type checker, v0.0.51) for type checking, rule diagnostics, and language server integration. Use when the user mentions ty type checking, Python type errors, ty check, ty rules, ty suppression, migrating from mypy or pyright to ty, configuring ty.toml or pyproject.toml type checking, or setting up a Python language server. ty is 10x-100x faster than mypy/Pyright and supports intersection types, redeclarations, and reachability-based analysis. |
| metadata | {"tags":["python","type-checking","linter"]} |
ty 0.0.51
Overview
ty is an extremely fast Python type checker and language server written in Rust, created by Astral (the team behind uv and Ruff). Version 0.0.51 uses 0.0.x versioning — the API is not yet stable, and breaking changes including diagnostic changes may occur between versions.
Key capabilities:
- Type checking —
ty check scans Python files for type errors with rich diagnostics
- Language server —
ty server provides IDE features (completions, go-to-definition, inlay hints, hover, rename, etc.)
- Rule configuration — configurable rule severities (
error, warn, ignore) via CLI flags or config files
- Suppression comments —
# ty: ignore[rule] inline suppression; also supports standard type: ignore
- Watch mode —
ty check --watch for incremental rechecking on file changes
Usage
Quick start
Run ty without installing via uvx:
uvx ty check
Or add as a dev dependency:
uv add --dev ty
uv run ty check
Type checking
ty check
ty check src/ tests/test_main.py
ty check --watch
ty check --quiet
ty check --verbose
Rule severity control
ty check --error possibly-missing-attribute --error possibly-missing-import
ty check --warn unused-ignore-comment
ty check --ignore redundant-cast
ty check --error all
Environment and module resolution
ty check --python .venv
ty check --python .venv/bin/python3
ty check --extra-search-path ./shared-stubs
ty check --python-version 3.12
ty check --python-platform linux
Output formats
ty check
ty check --output-format concise
ty check --output-format github
ty check --output-format gitlab
ty check --output-format junit
Exit codes
| Code | Meaning |
|---|
0 | No error-level violations |
1 | Error-level violations found |
2 | Invalid CLI options, config errors, or IO errors |
101 | Internal error |
Use --exit-zero to always exit 0, or --error-on-warning to treat warnings as failures.
Explaining rules
ty explain rule unresolved-import
ty explain rule
Language server
Start the LSP server for editor integration:
ty server
Supported LSP features: diagnostics, completions, go-to-definition/declaration/type-definition, find-references, hover, inlay hints, signature help, rename, document highlight, semantic tokens, code folding, notebook support, call/type hierarchy, selection range, and fine-grained incremental updates.
Shell autocompletion
eval "$(ty generate-shell-completion bash)"
eval "$(ty generate-shell-completion zsh)"
ty generate-shell-completion fish | source
Configuration
ty reads configuration from ty.toml (preferred) or [tool.ty] in pyproject.toml. User-level config lives at ~/.config/ty/ty.toml. Project config overrides user config; CLI flags override both.
Config file structure
[rules]
all = "warn"
possibly-unresolved-reference = "ignore"
redundant-cast = "ignore"
[analysis]
allowed-unresolved-imports = ["test.**", "!test.foo"]
replace-imports-with-any = ["pandas.**"]
[environment]
python-version = "3.12"
python-platform = "linux"
python = "./.venv"
extra-paths = ["./shared-stubs"]
root = [".", "./src"]
[src]
include = ["src", "tests"]
exclude = ["generated/**", "*.proto"]
respect-ignore-files = true
[terminal]
output-format = "concise"
error-on-warning = true
[[overrides]]
include = ["tests/**"]
[overrides.rules]
possibly-unresolved-reference = "ignore"
Key configuration sections
rules — Set severities: rule-name = "error" | "warn" | "ignore". Use all for global default.
analysis — allowed-unresolved-imports suppresses unresolved-import for glob patterns; replace-imports-with-any replaces module types with Any; respect-type-ignore-comments controls whether standard type: ignore works (default true).
environment — python-version (3.7–3.15), python-platform, python path, extra-paths, root for first-party module discovery, typeshed for custom stubs.
src — include/exclude globs, respect-ignore-files. Default excludes cover .git, node_modules, .venv, __pycache__, etc. Use !"pattern" to re-include.
terminal — output-format (full, concise, github, gitlab, junit), error-on-warning.
overrides — Per-glob rule and analysis overrides. Later overrides take precedence.
Gotchas
References
- 01-cli-reference — CLI commands, flags, and options
- 02-configuration — Config file format, sections, and settings
- 03-type-system — Redeclarations, intersection types, reachability analysis
- 04-rules — Rule list, severities, and suppression
- 05-editor-integration — VS Code, Neovim, Zed, PyCharm, Emacs setup
- 06-migration — Migrating from mypy or pyright to ty