The folks at Astral have released ty, which they define as:
An extremely fast Python type checker and language server, written in Rust.
You can read more in the blog post announcing it.
Today, I set it up with helix. To make it work, we first have to install it. Using uv, it’s as easy as typing:
sh
|
|
Then, edit your ~/.config/helix/languages.toml and add the following:
toml
|
|
At this point, you can start using it, but there are a few handy things to know:
- By default,
tywill search for first-party modules in the project’s root directory or thesrcdirectory, if present. - If they are located elsewhere, you need to update your
pyproject.tomllike so:
toml
|
|
- Third-party modules are searched for within a virtual environment, determined by:
- An environment variable called
VIRTUAL_ENV. - A
.venvdirectory in the project root or working directory. - The
--pythonor--venvflag when invoking it. - A configuration in
pyproject.toml:
- An environment variable called
toml
|
|
That’s it. Now, when editing files with hx, you should get all of ty’s goodness!