ruff/crates
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
..
ruff disable jemalloc on android (#18033) 2025-05-12 14:41:00 +02:00
ruff_annotate_snippets ruff_annotate_snippets: address unused code warnings 2025-04-07 08:24:08 -04:00
ruff_benchmark Avoid initializing progress bars early (#18049) 2025-05-12 15:07:55 -04:00
ruff_cache Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_db ruff_db: completely rip lint: prefix out 2025-05-09 12:42:14 -04:00
ruff_dev [ty] Remove brackets around option names (#18037) 2025-05-12 11:16:03 +00:00
ruff_diagnostics
ruff_formatter Fix typos (#17988) 2025-05-09 14:57:14 -04:00
ruff_graph [ty] Update salsa (#17964) 2025-05-09 11:54:07 +02:00
ruff_index Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_linter [pylint] add fix safety section (PLE4703) (#17824) 2025-05-12 16:27:54 -04:00
ruff_macros [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ruff_notebook Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_options_metadata [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ruff_python_ast Fix typos (#17988) 2025-05-09 14:57:14 -04:00
ruff_python_ast_integration_tests Visit Identifier node as part of the SourceOrderVisitor (#17110) 2025-04-01 16:58:09 +02:00
ruff_python_codegen Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_formatter Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_index Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_literal Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_parser Fix typos (#17988) 2025-05-09 14:57:14 -04:00
ruff_python_resolver Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_semantic [isort] Check full module path against project root(s) when categorizing first-party (#16565) 2025-05-05 11:40:01 -05:00
ruff_python_stdlib python_stdlib: update for 3.14 (#18014) 2025-05-11 11:25:54 -05:00
ruff_python_trivia Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_trivia_integration_tests
ruff_server Convert Message::SyntaxError to use Diagnostic internally (#17784) 2025-05-08 12:45:51 -04:00
ruff_source_file Convert Message::SyntaxError to use Diagnostic internally (#17784) 2025-05-08 12:45:51 -04:00
ruff_text_size Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_wasm Bump 0.11.9 (#17986) 2025-05-09 10:43:27 -05:00
ruff_workspace [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ty Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
ty_ide ty: switch to use annotate-snippets ID functionality 2025-05-09 12:42:14 -04:00
ty_project Avoid initializing progress bars early (#18049) 2025-05-12 15:07:55 -04:00
ty_python_semantic Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
ty_server Convert Message::SyntaxError to use Diagnostic internally (#17784) 2025-05-08 12:45:51 -04:00
ty_test Update --python to accept paths to executables in virtual environments (#17954) 2025-05-12 15:39:04 -05:00
ty_vendored [ty] Add support for __all__ (#17856) 2025-05-07 21:42:42 +05:30
ty_wasm Avoid initializing progress bars early (#18049) 2025-05-12 15:07:55 -04:00