[ty] Tell the user why we inferred the Python version we inferred (#18082)

This commit is contained in:
Alex Waygood 2025-05-21 11:06:27 -04:00 committed by GitHub
parent cb9e66927e
commit d37592175f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 303 additions and 124 deletions

View file

@ -978,7 +978,7 @@ mod tests {
use crate::module_name::ModuleName;
use crate::module_resolver::module::ModuleKind;
use crate::module_resolver::testing::{FileSpec, MockedTypeshed, TestCase, TestCaseBuilder};
use crate::{ProgramSettings, PythonPlatform};
use crate::{ProgramSettings, PythonPlatform, PythonVersionWithSource};
use super::*;
@ -1435,7 +1435,9 @@ mod tests {
fn symlink() -> anyhow::Result<()> {
use anyhow::Context;
use crate::{PythonPlatform, program::Program};
use crate::{
PythonPlatform, PythonVersionSource, PythonVersionWithSource, program::Program,
};
use ruff_db::system::{OsSystem, SystemPath};
use crate::db::tests::TestDb;
@ -1468,7 +1470,10 @@ mod tests {
Program::from_settings(
&db,
ProgramSettings {
python_version: PythonVersion::PY38,
python_version: PythonVersionWithSource {
version: PythonVersion::PY38,
source: PythonVersionSource::default(),
},
python_platform: PythonPlatform::default(),
search_paths: SearchPathSettings {
extra_paths: vec![],
@ -1984,7 +1989,7 @@ not_a_directory
Program::from_settings(
&db,
ProgramSettings {
python_version: PythonVersion::default(),
python_version: PythonVersionWithSource::default(),
python_platform: PythonPlatform::default(),
search_paths: SearchPathSettings {
extra_paths: vec![],
@ -2063,7 +2068,7 @@ not_a_directory
Program::from_settings(
&db,
ProgramSettings {
python_version: PythonVersion::default(),
python_version: PythonVersionWithSource::default(),
python_platform: PythonPlatform::default(),
search_paths: SearchPathSettings {
extra_paths: vec![],
@ -2106,7 +2111,7 @@ not_a_directory
Program::from_settings(
&db,
ProgramSettings {
python_version: PythonVersion::default(),
python_version: PythonVersionWithSource::default(),
python_platform: PythonPlatform::default(),
search_paths: SearchPathSettings {
extra_paths: vec![],

View file

@ -6,7 +6,9 @@ use ruff_python_ast::PythonVersion;
use crate::db::tests::TestDb;
use crate::program::{Program, SearchPathSettings};
use crate::{ProgramSettings, PythonPath, PythonPlatform};
use crate::{
ProgramSettings, PythonPath, PythonPlatform, PythonVersionSource, PythonVersionWithSource,
};
/// A test case for the module resolver.
///
@ -235,7 +237,10 @@ impl TestCaseBuilder<MockedTypeshed> {
Program::from_settings(
&db,
ProgramSettings {
python_version,
python_version: PythonVersionWithSource {
version: python_version,
source: PythonVersionSource::default(),
},
python_platform,
search_paths: SearchPathSettings {
extra_paths: vec![],
@ -293,7 +298,10 @@ impl TestCaseBuilder<VendoredTypeshed> {
Program::from_settings(
&db,
ProgramSettings {
python_version,
python_version: PythonVersionWithSource {
version: python_version,
source: PythonVersionSource::default(),
},
python_platform,
search_paths: SearchPathSettings {
python_path: PythonPath::KnownSitePackages(vec![site_packages.clone()]),