mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +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
|
@ -22,6 +22,7 @@ ruff_source_file = { workspace = true }
|
|||
ruff_text_size = { workspace = true }
|
||||
ruff_python_literal = { workspace = true }
|
||||
ruff_python_trivia = { workspace = true }
|
||||
ty_static = { workspace = true }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
bitflags = { workspace = true }
|
||||
|
@ -52,6 +53,7 @@ strum_macros = { workspace = true }
|
|||
ruff_db = { workspace = true, features = ["testing", "os"] }
|
||||
ruff_python_parser = { workspace = true }
|
||||
ty_python_semantic = { workspace = true, features = ["testing"] }
|
||||
ty_static = { workspace = true }
|
||||
ty_test = { workspace = true }
|
||||
ty_vendored = { workspace = true }
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use camino::Utf8Path;
|
||||
use dir_test::{Fixture, dir_test};
|
||||
use ty_static::EnvVars;
|
||||
use ty_test::OutputFormat;
|
||||
|
||||
/// See `crates/ty_test/README.md` for documentation on these tests.
|
||||
|
@ -19,7 +20,7 @@ fn mdtest(fixture: Fixture<&str>) {
|
|||
|
||||
let test_name = test_name("mdtest", absolute_fixture_path);
|
||||
|
||||
let output_format = if std::env::var("MDTEST_GITHUB_ANNOTATIONS_FORMAT").is_ok() {
|
||||
let output_format = if std::env::var(EnvVars::MDTEST_GITHUB_ANNOTATIONS_FORMAT).is_ok() {
|
||||
OutputFormat::GitHub
|
||||
} else {
|
||||
OutputFormat::Cli
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue