mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 23:25:14 +00:00
Change EnvironmentOptions::venv-path
to Option<SystemPathBuf>
(#15631)
## Summary The `Options` struct is intended to capture the user's configuration options but `EnvironmentOptions::venv_path` supports both a `SitePackages::Known` and `SitePackages::Derived`. Users should only be able to provide `SitePackages::Derived`—they specify a path to a venv, and Red Knot derives the path to the site-packages directory. We'll only use the `Known` variant once we automatically discover the Python installation. That's why this PR changes `EnvironmentOptions::venv_path` from `Option<SitePackages>` to `Option<SystemPathBuf>`. This requires making some changes to the file watcher test, and I decided to use `extra_paths` over venv path because our venv validation is annoyingly correct -- making mocking a venv rather involved. ## Test Plan `cargo test`
This commit is contained in:
parent
4366473d9b
commit
067c6de465
5 changed files with 19 additions and 27 deletions
|
@ -222,8 +222,14 @@ impl SearchPaths {
|
|||
static_paths.push(stdlib_path);
|
||||
|
||||
let site_packages_paths = match site_packages_paths {
|
||||
SitePackages::Derived { venv_path } => VirtualEnvironment::new(venv_path, system)
|
||||
.and_then(|venv| venv.site_packages_directories(system))?,
|
||||
SitePackages::Derived { venv_path } => {
|
||||
// TODO: We may want to warn here if the venv's python version is older
|
||||
// than the one resolved in the program settings because it indicates
|
||||
// that the `target-version` is incorrectly configured or that the
|
||||
// venv is out of date.
|
||||
VirtualEnvironment::new(venv_path, system)
|
||||
.and_then(|venv| venv.site_packages_directories(system))?
|
||||
}
|
||||
SitePackages::Known(paths) => paths
|
||||
.iter()
|
||||
.map(|path| canonicalize(path, system))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue