ty 0.0.49
ty is an extremely fast Python type checker and language server written in Rust, by Astral (creators of uv and Ruff). It offers 10x–100x speedups over mypy and Pyright while providing comprehensive diagnostics, rich editor integration, and advanced type system features like intersection types and reachability-based analysis.
Overview
ty provides two main capabilities:
- Type checking (
ty check) — Fast static type analysis of Python code with configurable rules, per-file overrides, and suppression comments
- Language server (
ty server) — Full LSP implementation with completions, hover, go-to-definition, rename, inlay hints, signature help, and more
Key design principles:
- Supports partially typed code (gradual guarantee) — no errors for missing annotations by default
- Allows redeclarations of symbols within the same scope
- First-class intersection types for precise narrowing
- Reachability analysis based on type inference (not just pattern matching)
- Fine-grained incremental analysis for sub-millisecond IDE feedback
ty is currently in beta with 0.0.x versioning. Breaking changes can occur between any two versions.
Usage
Quick start
# Run without installation via uvx
uvx ty check
# Or inside a project with uv
uv run ty check
Type checking
# Check all Python files in current directory/project
ty check
# Check specific files or directories
ty check src/ tests/test_main.py
# Watch mode — recheck on file changes (uses fine-grained incrementality)
ty check --watch
# Set Python version explicitly
ty check --python-version 3.12
# Point to a custom virtual environment
ty check --python .venv
# Adjust rule severity on the command line
ty check --error all --ignore redundant-cast --warn unused-ignore-comment
# CI-friendly output formats
ty check --output-format github # GitHub Actions annotations
ty check --output-format gitlab # GitLab Code Quality JSON
ty check --output-format junit # JUnit XML report
ty check --output-format concise # One diagnostic per line
Language server
# Start the LSP server (used by editors)
ty server
Editors connect to ty server automatically. See reference files for editor-specific setup.
Explain rules
# Get documentation for a specific rule
ty explain rule invalid-argument-type
# List all rules
ty explain rule
Version info
ty version
ty version --output-format json
Gotchas
ty does not warn about missing type annotations. Unlike mypy's disallow_untyped_defs, ty treats unannotated symbols as Unknown and only reports errors when the unknown type causes a concrete problem. Use Ruff's flake8-annotations (ANN) rules if you need to enforce annotation coverage.
float annotations accept int too. Per the Python typing spec, float means int | float. If you need strictly float, use ty_extensions.JustFloat behind a TYPE_CHECKING guard. Same for complex → JustComplex.
Generic containers are invariant. list[Subtype] is not assignable to list[Supertype] because lists are mutable. Use Sequence[T] (covariant) when mutation isn't needed, or explicitly widen the annotation.
Top[list[Unknown]] in narrowing results. When checking isinstance(x, list) on a union type like Item | list[Item], ty accounts for possible subclasses of both Item and list. Use @final on Item or check isinstance(x, Item) first to get cleaner narrowing.
ty does not support mypy plugins. There is no plugin system. Support for popular libraries (pydantic, SQLAlchemy, attrs, django) may be added directly into ty over time.
Configuration file precedence: ty.toml overrides [tool.ty] in pyproject.toml when both exist in the same directory. CLI flags override all files. Project-level config overrides user-level (~/.config/ty/ty.toml).
Virtual environment discovery: ty checks VIRTUAL_ENV, then looks for .venv in project root, then falls back to python3/python on PATH. When using uv run, the venv is detected automatically via VIRTUAL_ENV.
Suppression comments use ty: ignore, not type: ignore. ty supports both formats, but type: ignore suppresses all violations on a line. Use ty: ignore[rule] for targeted suppression. The type: ignore[ty:rule] format works too and is useful when mixing multiple type checkers.
Exit code 2 means configuration/CLI errors. Exit code 0 = no errors, 1 = type errors found, 2 = bad config or CLI options, 101 = internal error. Use --exit-zero to always return 0; use --error-on-warning to treat warnings as failures.
References
Detailed reference material loaded on demand:
- Installation methods — uvx, pip, standalone installer, Docker, Bazel, shell completion
- Configuration — pyproject.toml / ty.toml settings, overrides, environment options
- Type system features — redeclarations, intersection types, gradual typing, reachability analysis
- Language server and editors — LSP features, VS Code, Neovim, Zed, PyCharm, Emacs settings
- Rules and suppression — rule levels, suppression comments, migration from mypy/pyright
- Environment variables — TY_CONFIG_FILE, TY_LOG, PYTHONPATH, VIRTUAL_ENV, and more
1---2name: ty-0-0-493description: Use ty, the extremely fast Python type checker and language server by Astral (creators of uv and Ruff). Use this skill whenever the user mentions ty, Python type checking, mypy migration, pyright migration, type diagnostics, or needs to configure a Python type checker. Also triggers for questions about Python typing features like intersection types, gradual typing, or redeclarations. ty is 10x–100x faster than mypy/Pyright and supports full LSP (completions, hover, navigate, etc.).4---56# ty 0.0.4978ty is an extremely fast Python type checker and language server written in Rust, by Astral (creators of uv and Ruff). It offers 10x–100x speedups over mypy and Pyright while providing comprehensive diagnostics, rich editor integration, and advanced type system features like intersection types and reachability-based analysis.910## Overview1112ty provides two main capabilities:1314- **Type checking** (`ty check`) — Fast static type analysis of Python code with configurable rules, per-file overrides, and suppression comments15- **Language server** (`ty server`) — Full LSP implementation with completions, hover, go-to-definition, rename, inlay hints, signature help, and more1617Key design principles:1819- Supports partially typed code (gradual guarantee) — no errors for missing annotations by default20- Allows redeclarations of symbols within the same scope21- First-class intersection types for precise narrowing22- Reachability analysis based on type inference (not just pattern matching)23- Fine-grained incremental analysis for sub-millisecond IDE feedback2425ty is currently in beta with `0.0.x` versioning. Breaking changes can occur between any two versions.2627## Usage2829### Quick start3031```bash32# Run without installation via uvx33uvx ty check3435# Or inside a project with uv36uv run ty check37```3839### Type checking4041```bash42# Check all Python files in current directory/project43ty check4445# Check specific files or directories46ty check src/ tests/test_main.py4748# Watch mode — recheck on file changes (uses fine-grained incrementality)49ty check --watch5051# Set Python version explicitly52ty check --python-version 3.125354# Point to a custom virtual environment55ty check --python .venv5657# Adjust rule severity on the command line58ty check --error all --ignore redundant-cast --warn unused-ignore-comment5960# CI-friendly output formats61ty check --output-format github # GitHub Actions annotations62ty check --output-format gitlab # GitLab Code Quality JSON63ty check --output-format junit # JUnit XML report64ty check --output-format concise # One diagnostic per line65```6667### Language server6869```bash70# Start the LSP server (used by editors)71ty server72```7374Editors connect to `ty server` automatically. See reference files for editor-specific setup.7576### Explain rules7778```bash79# Get documentation for a specific rule80ty explain rule invalid-argument-type8182# List all rules83ty explain rule84```8586### Version info8788```bash89ty version90ty version --output-format json91```9293## Gotchas9495- **ty does not warn about missing type annotations.** Unlike mypy's `disallow_untyped_defs`, ty treats unannotated symbols as `Unknown` and only reports errors when the unknown type causes a concrete problem. Use Ruff's `flake8-annotations` (ANN) rules if you need to enforce annotation coverage.9697- **`float` annotations accept `int` too.** Per the Python typing spec, `float` means `int | float`. If you need strictly `float`, use `ty_extensions.JustFloat` behind a `TYPE_CHECKING` guard. Same for `complex` → `JustComplex`.9899- **Generic containers are invariant.** `list[Subtype]` is not assignable to `list[Supertype]` because lists are mutable. Use `Sequence[T]` (covariant) when mutation isn't needed, or explicitly widen the annotation.100101- **`Top[list[Unknown]]` in narrowing results.** When checking `isinstance(x, list)` on a union type like `Item | list[Item]`, ty accounts for possible subclasses of both `Item` and `list`. Use `@final` on `Item` or check `isinstance(x, Item)` first to get cleaner narrowing.102103- **ty does not support mypy plugins.** There is no plugin system. Support for popular libraries (pydantic, SQLAlchemy, attrs, django) may be added directly into ty over time.104105- **Configuration file precedence:** `ty.toml` overrides `[tool.ty]` in `pyproject.toml` when both exist in the same directory. CLI flags override all files. Project-level config overrides user-level (`~/.config/ty/ty.toml`).106107- **Virtual environment discovery:** ty checks `VIRTUAL_ENV`, then looks for `.venv` in project root, then falls back to `python3`/`python` on PATH. When using `uv run`, the venv is detected automatically via `VIRTUAL_ENV`.108109- **Suppression comments use `ty: ignore`, not `type: ignore`.** ty supports both formats, but `type: ignore` suppresses all violations on a line. Use `ty: ignore[rule]` for targeted suppression. The `type: ignore[ty:rule]` format works too and is useful when mixing multiple type checkers.110111- **Exit code 2 means configuration/CLI errors.** Exit code 0 = no errors, 1 = type errors found, 2 = bad config or CLI options, 101 = internal error. Use `--exit-zero` to always return 0; use `--error-on-warning` to treat warnings as failures.112113## References114115Detailed reference material loaded on demand:116117- [Installation methods](references/01-installation.md) — uvx, pip, standalone installer, Docker, Bazel, shell completion118- [Configuration](references/02-configuration.md) — pyproject.toml / ty.toml settings, overrides, environment options119- [Type system features](references/03-type-system.md) — redeclarations, intersection types, gradual typing, reachability analysis120- [Language server and editors](references/04-language-server.md) — LSP features, VS Code, Neovim, Zed, PyCharm, Emacs settings121- [Rules and suppression](references/05-rules-and-suppression.md) — rule levels, suppression comments, migration from mypy/pyright122- [Environment variables](references/06-environment.md) — TY_CONFIG_FILE, TY_LOG, PYTHONPATH, VIRTUAL_ENV, and more