mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:26 +00:00
[ty] Move venv and conda env discovery to SearchPath::from_settings
(#18938)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
d04e63a6d9
commit
76387295a5
14 changed files with 147 additions and 108 deletions
|
@ -9,7 +9,7 @@ use ruff_db::{Db as SourceDb, Upcast};
|
|||
use ruff_python_ast::PythonVersion;
|
||||
use ty_python_semantic::lint::{LintRegistry, RuleSelection};
|
||||
use ty_python_semantic::{
|
||||
Db, Program, ProgramSettings, PythonPath, PythonPlatform, PythonVersionSource,
|
||||
Db, Program, ProgramSettings, PythonEnvironmentPath, PythonPlatform, PythonVersionSource,
|
||||
PythonVersionWithSource, SearchPathSettings, SysPrefixPathOrigin, default_lint_registry,
|
||||
};
|
||||
|
||||
|
@ -36,11 +36,11 @@ impl ModuleDb {
|
|||
venv_path: Option<SystemPathBuf>,
|
||||
) -> Result<Self> {
|
||||
let mut search_paths = SearchPathSettings::new(src_roots);
|
||||
// TODO: Consider setting `PythonPath::Auto` if no venv_path is provided.
|
||||
if let Some(venv_path) = venv_path {
|
||||
search_paths.python_path =
|
||||
PythonPath::sys_prefix(venv_path, SysPrefixPathOrigin::PythonCliFlag);
|
||||
search_paths.python_environment =
|
||||
PythonEnvironmentPath::explicit(venv_path, SysPrefixPathOrigin::PythonCliFlag);
|
||||
}
|
||||
|
||||
let db = Self::default();
|
||||
let search_paths = search_paths
|
||||
.to_search_paths(db.system(), db.vendored())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue