ty: Python Type Checker by Astral
ty (pronounced tee-why) is a static type checker and language server for Python from Astral (creators of Ruff and uv). It performs static analysis on Python code to identify type-related issues before runtime.
Key Features
- Performance: 10-100x faster than mypy and Pyright. Fine-grained incremental analysis provides near-instant feedback in an IDE.
- Diagnostics: Detailed error messages with code-span annotations and rich contextual information.
- Language Server: Full LSP implementation with go-to-definition, find references, completions with auto-import, rename refactoring, inlay hints, hover, and signature help.
- Configurable Rules: Each diagnostic rule can be set to error, warn, or ignore. Supports per-file overrides and suppression comments.
- Gradual Typing: Avoids false positives on untyped code through a “gradual guarantee” approach, making adoption in existing codebases practical.
- Advanced Type System: First-class intersection types, type narrowing (including
hasattrnarrowing), and reachability analysis based on type inference. - Notebook Support: Language server features for Jupyter notebooks with cross-cell analysis.
Type System Features
ty implements several type system features beyond what other type checkers provide:
- Redeclarations: Allows reusing the same symbol with a different type within a function scope.
- Intersection Types: First-class support for intersection types (
A & B), which enables more precise type narrowing afterisinstancechecks. - Reachability Analysis: Uses type inference to detect unreachable branches, which can handle version-specific code paths for libraries like pydantic.
- Fixpoint Iteration: Infers types for symbols that cyclically depend on themselves by iterating until the type converges.
Installation
The quickest way to run ty is with uvx:
uvx ty checkFor project use, add ty as a development dependency:
uv add --dev ty
uv run ty checkty can also be installed globally with uv tool install ty@latest, via pip, pipx, or using standalone installers available for macOS, Linux, and Windows.
Basic Usage
# Check the current project
ty check
# Check specific files
ty check src/main.py
# Check with a specific Python version target
ty check --python-version 3.12
# Get an explanation of a specific rule
ty explain rule <rule-name>
# Show all rules
ty explain ruleConfiguration
ty reads configuration from pyproject.toml (under [tool.ty]) or a dedicated ty.toml file. Rule levels and other settings can be configured per-project:
[tool.ty.rules]
unused-ignore-comment = "warn"
possibly-missing-import = "error"User-level configuration is also supported at ~/.config/ty/ty.toml.
Editor Integration
ty includes official editor support:
- VS Code: Install the ty extension from the VS Code Marketplace.
- Neovim: Configure via
nvim-lspconfigor the built-invim.lsp.config(Neovim 0.11+). - Zed: Built-in support (can be enabled in settings).
- PyCharm: Native support starting with version 2025.3.
For other editors, run ty server to start the language server.
Comparison to Other Tools
ty is not a drop-in replacement for mypy or Pyright — it makes different design choices and has different default behaviors. The primary differentiators are speed (orders of magnitude faster) and the gradual typing approach that reduces false positives on untyped code. ty aims for conformance with the Python typing specification.
Learn More
- ty: A Complete Guide
- How do mypy, pyright, and ty compare?
- How to try the ty type checker
- How to migrate from mypy to ty
- How to use ty in CI
- How to gradually adopt type checking in an existing Python project
- ty Documentation
- ty Playground
- ty GitHub Repository
Also Mentioned In
- ty: A Complete Guide to Python's Fastest Type Checker
- Ruff: A Complete Guide to Python's Fastest Linter and Formatter
- OpenAI to Acquire Astral
- Charlie Marsh on uv, Coding Agents, and the Changing Open Source Contract
- ty is Built with AI
- ty: Astral's New Python Type Checker Released
- Google Sunsets Pytype: The End of an Era for Python Type Checking
- ty's Breakthrough: Why Incremental Analysis Matters for Python
- How Python's RFC Process Paved the Way for uv, Ruff, and Ty
- Comparison of the Two New Typecheckers
- Early Explorations of Astral's Red Knot Type Checker
- How do mypy, pyright, and ty compare?
- How do Ruff and Pylint compare?
- How to configure Cursor for a uv project
- How to configure VS Code for a uv project
- How to gradually adopt type checking in an existing Python project
- How to migrate from mypy to ty
- How to try the ty type checker
- How to use ty in CI
- mypy: Python Static Type Checker
- Pyright: Python Static Type Checker by Microsoft
- Ruff: Python Linter and Formatter
Get Python tooling updates
Subscribe to the newsletter