| .github | ||
| docs | ||
| python/ty | ||
| ruff@7a48477c67 | ||
| scripts | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .gitmodules | ||
| .markdownlint.yaml | ||
| .pre-commit-config.yaml | ||
| .python-version | ||
| _typos.toml | ||
| CHANGELOG.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| dist-workspace.toml | ||
| Dockerfile | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| SECURITY.md | ||
| uv.lock | ||
ty
An extremely fast Python type checker and language server, written in Rust.
Warning
ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
ty is in active development, and we're working hard to make it stable and feature-complete.
Getting started
Installation
uv tool install ty
or add ty to your project:
uv add --dev ty
# With pip.
pip install ty
First steps
After installing ty, you can check that ty is available by running the ty command:
ty
An extremely fast Python type checker.
Usage: ty <COMMAND>
...
You should see a help menu listing the available commands.
For detailed information about command-line options, see the CLI documentation.
Checking your project
ty check
Editor integration
ty can be integrated with various editors and IDEs to provide a seamless development experience. This section provides instructions on how to set up ty with your editor and configure it to your liking.
VS Code
Install the ty extension from the VS Code Marketplace.
For more documentation on the ty extension, refer to the extension's README.
Other editors
ty can be used with any editor that supports the language server protocol. To start the language server, run ty server. Refer to your editor's documentation
to learn how to connect to an LSP server.
Configuration
Configuration files
ty supports persistent configuration files at both the project- and user-level.
Specifically, ty will search for a pyproject.toml or ty.toml file in the current directory, or in the nearest parent directory.
If a pyproject.toml file is found, ty will read configuration from the [tool.ty] table. For example, to ignore the index-out-of-bounds rule, add the following to a pyproject.toml:
pyproject.toml:
[tool.ty.rules]
index-out-of-bounds = "ignore"
(If there is no tool.ty table, the pyproject.toml file will be ignored, and ty will continue searching in the directory hierarchy.)
ty will also search for ty.toml files, which follow an identical structure, but omit the [tool.ty] prefix. For example:
ty.toml:
[rules]
index-out-of-bounds = "ignore"
Note
ty.tomlfiles take precedence overpyproject.tomlfiles, so if bothty.tomlandpyproject.tomlfiles are present in a directory, configuration will be read fromty.toml, and the[tool.ty]section in the accompanyingpyproject.tomlwill be ignored.
ty will also discover user-level configuration at ~/.config/ty/ty.toml (or $XDG_CONFIG_HOME/ty/ty.toml) on macOS and Linux, or %APPDATA%\ty\ty.toml on Windows. User-level configuration must use the ty.toml format, rather than the pyproject.toml format, as a pyproject.toml is intended to define a Python project.
If project- and user-level configuration files are found, the settings will be merged, with project-level configuration taking precedence over the user-level configuration.
For example, if a string, number, or boolean is present in both the project- and user-level configuration tables, the project-level value will be used, and the user-level value will be ignored. If an array is present in both tables, the arrays will be merged, with the project-level settings appearing later in the merged array.
Settings provided via command line take precedence over persistent configuration.
See the settings reference for an enumeration of the available settings.
Environment variables
ty defines and respects the following environment variables:
TY_LOG
If set, ty will use this value as the log level for its --verbose output. Accepts any filter compatible with the tracing_subscriber crate. For example:
TY_LOG=uv=debugis the equivalent of-vvto the command lineTY_LOG=tracewill enable all trace-level logging.
See the tracing documentation for more.
TY_MAX_PARALLELISM
Specifies an upper limit for the number of tasks ty is allowed to run in parallel. For example, how many files should be checked in parallel.
This isn’t the same as a thread limit. ty may spawn additional threads when necessary, e.g. to watch for file system changes or a dedicated UI thread.
Externally defined variables
ty also reads the following externally defined environment variables:
RAYON_NUM_THREADS
Specifies an upper limit for the number of threads ty uses when performing work in parallel. Equivalent to TY_MAX_PARALLELISM.
VIRTUAL_ENV
Used to detect an activated virtual environment.
XDG_CONFIG_HOME
Path to user-level configuration directory on Unix systems.
Reference
Getting involved
If you have questions or want to report a bug, please open an issue in this repository.
Development of this project takes place in the Ruff repository
at this time. Please open pull requests there for changes
to anything in the ruff submodule (which includes all of the Rust source code).
See the contributing guide for more details.
License
ty is licensed under the MIT license (LICENSE or https://opensource.org/licenses/MIT).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ty by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.