ty
ty (pronounced tee-why) is a static type checker for Python being developed by Astral (creators of Ruff and uv). It performs static analysis on Python code to identify type-related issues before runtime, with a focus on performance, detailed error messages, and incremental analysis capabilities.
Key Features
- Static Type Analysis: Checks your Python code based on type annotations to find potential errors.
- High Performance: A core goal is to be significantly faster than existing Python type checkers, particularly for large codebases.
- Informative Diagnostics: Provides detailed error messages that aim to explain not just what went wrong, but also why and how you might fix it.
- Language Server Capabilities: Planned to power a language server (LSP) for integration with code editors, offering features like real-time diagnostics, autocompletion, and go-to-definition.
- Standards Conformance: Aims to conform to the Python typing specification and pass the relevant conformance suite.
- Gradual Adoption Friendly: Designed to be less opinionated than some existing type checkers, aiming to reduce false positives on untyped code and support gradual adoption of types.
- Inline Type Hints: Displays inferred types directly in the editor or playground environment.
Relationship with Ruff and uv
ty is closely related to Ruff and uv. It is currently developed within the Ruff codebase and shares foundational components like the parser and Abstract Syntax Tree. Although there was consideration for integrating type checking more directly into Ruff’s linting rules, the decision was made to release ty as a separate, dedicated type checking tool.
Roadmap & Release
An early experimental preview alpha release of ty is anticipated by PyCon 2025. This initial release is primarily for experimentation and demonstration of core capabilities; it will not be feature-complete and may contain bugs. A beta release is planned for later in 2025.
The goal for a generally available, production-ready release is sometime in late 2025. While LSP support is present in early stages, the initial focus for editor integration will be on core code navigation features rather than a full suite of LSP capabilities.
Comparison to Other Tools
While not designed as a direct drop-in replacement for established tools like mypy or Pyright, primarily due to different design choices, ty aims for significantly faster performance. It aims to be less opinionated and facilitating easier gradual adoption in existing projects compared to current options. ty does aim for standards conformance, aligning with other type checkers in implementing the Python typing specification.
Learn More: