mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[ty] Infer the Python version from the environment if feasible (#18057)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
9bbf4987e8
commit
88866f0048
19 changed files with 582 additions and 165 deletions
|
@ -677,7 +677,7 @@ mod tests {
|
|||
Program::from_settings(
|
||||
&db,
|
||||
ProgramSettings {
|
||||
python_version: PythonVersionWithSource::default(),
|
||||
python_version: Some(PythonVersionWithSource::default()),
|
||||
python_platform: PythonPlatform::default(),
|
||||
search_paths: SearchPathSettings::new(vec![SystemPathBuf::from(".")]),
|
||||
},
|
||||
|
|
|
@ -11,8 +11,8 @@ use std::fmt::Debug;
|
|||
use thiserror::Error;
|
||||
use ty_python_semantic::lint::{GetLintError, Level, LintSource, RuleSelection};
|
||||
use ty_python_semantic::{
|
||||
ProgramSettings, PythonPath, PythonPlatform, PythonVersionSource, PythonVersionWithSource,
|
||||
SearchPathSettings,
|
||||
ProgramSettings, PythonPath, PythonPlatform, PythonVersionFileSource, PythonVersionSource,
|
||||
PythonVersionWithSource, SearchPathSettings,
|
||||
};
|
||||
|
||||
use super::settings::{Settings, TerminalSettings};
|
||||
|
@ -88,12 +88,11 @@ impl Options {
|
|||
version: **ranged_version,
|
||||
source: match ranged_version.source() {
|
||||
ValueSource::Cli => PythonVersionSource::Cli,
|
||||
ValueSource::File(path) => {
|
||||
PythonVersionSource::File(path.clone(), ranged_version.range())
|
||||
}
|
||||
ValueSource::File(path) => PythonVersionSource::ConfigFile(
|
||||
PythonVersionFileSource::new(path.clone(), ranged_version.range()),
|
||||
),
|
||||
},
|
||||
})
|
||||
.unwrap_or_default();
|
||||
});
|
||||
let python_platform = self
|
||||
.environment
|
||||
.as_ref()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue