Ty: An Extremely Fast Python Type Checker Written in Rust

Programming Tools

Discover Ty, an ultra-fast Python type checker built with Rust. Learn how to quickly install, run type checks across your project, and understand its module discovery for efficient code analysis and improved code quality.

Ty is an exceptionally fast Python type checker, meticulously developed in Rust.

Getting Started

To begin using Ty, you can explore the online playground or quickly install it using uvx:

uvx ty

For comprehensive installation instructions, please consult the dedicated documentation. If no subcommand is provided when running ty, it will display a list of available commands. For detailed information on command-line options, refer to the CLI reference.

Running Type Checks

To execute the type checker, use the check command:

uvx ty check

When invoked without specific paths, Ty will automatically scan all Python files within the current working directory and its subdirectories. In a project context, Ty will commence its scan from the directory containing the pyproject.toml file.

You can also specify particular files or directories for type checking:

uvx ty check example.py

During type checking, Ty identifies installed packages within the active virtual environment (via the VIRTUAL_ENV variable) or by locating a .venv directory in the project root or working directory. It will not detect packages in non-virtual environments unless the target Python path is explicitly provided using the --python flag. Further details on module discovery can be found in the relevant documentation.

Usage Best Practices

To check your project for type errors using Ty's default configuration, navigate to your project's top-level directory and run ty check.

Should this action result in a multitude of errors, especially if you are using the standard library venv module for your virtual environment, it is recommended to add the venv directory to your .gitignore or .ignore file and then retry the type check. This prevents ty from scanning the virtual environment's own Python files, which can often generate noise rather than meaningful project-specific errors.