ruff/crates/ty
Zanie Blue 6b64630635
Update --python to accept paths to executables in virtual environments (#17954)
## Summary

Updates the `--python` flag to accept Python executables in virtual
environments. Notably, we do not query the executable and it _must_ be
in a canonical location in a virtual environment. This is pretty naive,
but solves for the trivial case of `ty check --python .venv/bin/python3`
which will be a common mistake (and `ty check --python $(which python)`)

I explored this while trying to understand Python discovery in ty in
service of https://github.com/astral-sh/ty/issues/272, I'm not attached
to it, but figure it's worth sharing.

As an alternative, we can add more variants to the
`SearchPathValidationError` and just improve the _error_ message, i.e.,
by hinting that this looks like a virtual environment and suggesting the
concrete alternative path they should provide. We'll probably want to do
that for some other cases anyway (e.g., `3.13` as described in the
linked issue)

This functionality is also briefly mentioned in
https://github.com/astral-sh/ty/issues/193

Closes https://github.com/astral-sh/ty/issues/318

## Test Plan

e.g.,

```
uv run ty check --python .venv/bin/python3
```

needs test coverage still
2025-05-12 15:39:04 -05:00
..
docs Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
src Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
tests Avoid initializing progress bars early (#18049) 2025-05-12 15:07:55 -04:00
build.rs Parse dist-workspace.toml for version (#17868) 2025-05-06 12:18:17 +00:00
Cargo.toml Add progress bar for ty check (#17965) 2025-05-09 13:32:27 -04:00
README.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00

ty

ty is an extremely fast type checker. Currently, it is a work-in-progress and not ready for user testing.

ty is designed to prioritize good type inference, even in unannotated code, and aims to avoid false positives.

While ty will produce similar results to mypy and pyright on many codebases, 100% compatibility with these tools is a non-goal. On some codebases, ty's design decisions lead to different outcomes than you would get from running one of these more established tools.

Contributing

Core type checking tests are written as Markdown code blocks. They can be found in ty_python_semantic/resources/mdtest. See ty_test/README.md for more information on the test framework itself.

The list of open issues can be found here.