From 1a3b1e4e839edb81547bc4d081c0358bf8eac0d9 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 9 Jul 2024 17:45:56 -0500 Subject: [PATCH] Add support for any Python requests --- crates/uv-python/src/discovery.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index 0b68a8f1677d..bbdd364718c5 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -974,6 +974,11 @@ impl PythonRequest { /// /// This cannot fail, which means weird inputs will be parsed as [`PythonRequest::File`] or [`PythonRequest::ExecutableName`]. pub fn parse(value: &str) -> Self { + // e.g. `any` + if value.eq_ignore_ascii_case("any") { + return Self::Any; + } + // e.g. `3.12.1`, `312`, or `>=3.12` if let Ok(version) = VersionRequest::from_str(value) { return Self::Version(version); @@ -1581,6 +1586,7 @@ mod tests { #[test] fn interpreter_request_from_str() { + assert_eq!(PythonRequest::parse("any"), PythonRequest::Any); assert_eq!( PythonRequest::parse("3.12"), PythonRequest::Version(VersionRequest::from_str("3.12").unwrap())