mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:47 +00:00
[ty] Tell the user why we inferred the Python version we inferred (#18082)
This commit is contained in:
parent
cb9e66927e
commit
d37592175f
20 changed files with 303 additions and 124 deletions
|
@ -663,10 +663,11 @@ mod tests {
|
|||
use ruff_db::source::source_text;
|
||||
use ruff_db::system::{DbWithTestSystem, DbWithWritableSystem as _, SystemPath, SystemPathBuf};
|
||||
use ruff_db::testing::assert_function_query_was_not_run;
|
||||
use ruff_python_ast::PythonVersion;
|
||||
use ruff_python_ast::name::Name;
|
||||
use ty_python_semantic::types::check_types;
|
||||
use ty_python_semantic::{Program, ProgramSettings, PythonPlatform, SearchPathSettings};
|
||||
use ty_python_semantic::{
|
||||
Program, ProgramSettings, PythonPlatform, PythonVersionWithSource, SearchPathSettings,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn check_file_skips_type_checking_when_file_cant_be_read() -> ruff_db::system::Result<()> {
|
||||
|
@ -677,7 +678,7 @@ mod tests {
|
|||
Program::from_settings(
|
||||
&db,
|
||||
ProgramSettings {
|
||||
python_version: PythonVersion::default(),
|
||||
python_version: PythonVersionWithSource::default(),
|
||||
python_platform: PythonPlatform::default(),
|
||||
search_paths: SearchPathSettings::new(vec![SystemPathBuf::from(".")]),
|
||||
},
|
||||
|
|
|
@ -10,7 +10,10 @@ use serde::{Deserialize, Serialize};
|
|||
use std::fmt::Debug;
|
||||
use thiserror::Error;
|
||||
use ty_python_semantic::lint::{GetLintError, Level, LintSource, RuleSelection};
|
||||
use ty_python_semantic::{ProgramSettings, PythonPath, PythonPlatform, SearchPathSettings};
|
||||
use ty_python_semantic::{
|
||||
ProgramSettings, PythonPath, PythonPlatform, PythonVersionSource, PythonVersionWithSource,
|
||||
SearchPathSettings,
|
||||
};
|
||||
|
||||
use super::settings::{Settings, TerminalSettings};
|
||||
|
||||
|
@ -93,8 +96,17 @@ impl Options {
|
|||
let python_version = self
|
||||
.environment
|
||||
.as_ref()
|
||||
.and_then(|env| env.python_version.as_deref().copied())
|
||||
.unwrap_or(PythonVersion::latest_ty());
|
||||
.and_then(|env| env.python_version.as_ref())
|
||||
.map(|ranged_version| PythonVersionWithSource {
|
||||
version: **ranged_version,
|
||||
source: match ranged_version.source() {
|
||||
ValueSource::Cli => PythonVersionSource::Cli,
|
||||
ValueSource::File(path) => {
|
||||
PythonVersionSource::File(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