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:
Micha Reiser 2025-01-21 15:10:41 +01:00 committed by GitHub
parent 4366473d9b
commit 067c6de465
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 27 deletions

View file

@ -134,12 +134,3 @@ pub enum SitePackages {
/// Resolved site packages paths
Known(Vec<SystemPathBuf>),
}
impl SitePackages {
pub fn paths(&self) -> &[SystemPathBuf] {
match self {
SitePackages::Derived { venv_path } => std::slice::from_ref(venv_path),
SitePackages::Known(paths) => paths,
}
}
}