mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
Auto-generate environment variable references for ty (#19205)
## Summary
This PR mirrors the environment variable implementation we have in uv:
efc361223c/crates/uv-static/src/env_vars.rs (L6-L7)
.
See: https://github.com/astral-sh/ty/issues/773.
This commit is contained in:
parent
149350bf39
commit
3ee3434187
24 changed files with 458 additions and 14 deletions
|
@ -23,6 +23,7 @@ use ruff_python_ast::PythonVersion;
|
|||
use ruff_python_trivia::Cursor;
|
||||
use ruff_source_file::{LineIndex, OneIndexed, SourceCode};
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
use ty_static::EnvVars;
|
||||
|
||||
type SitePackagesDiscoveryResult<T> = Result<T, SitePackagesDiscoveryError>;
|
||||
|
||||
|
@ -149,7 +150,7 @@ impl PythonEnvironment {
|
|||
PythonEnvironment::new(path, origin, system)
|
||||
}
|
||||
|
||||
if let Ok(virtual_env) = system.env_var("VIRTUAL_ENV") {
|
||||
if let Ok(virtual_env) = system.env_var(EnvVars::VIRTUAL_ENV) {
|
||||
return resolve_environment(
|
||||
system,
|
||||
SystemPath::new(&virtual_env),
|
||||
|
@ -158,7 +159,7 @@ impl PythonEnvironment {
|
|||
.map(Some);
|
||||
}
|
||||
|
||||
if let Ok(conda_env) = system.env_var("CONDA_PREFIX") {
|
||||
if let Ok(conda_env) = system.env_var(EnvVars::CONDA_PREFIX) {
|
||||
return resolve_environment(
|
||||
system,
|
||||
SystemPath::new(&conda_env),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue