From 3d1ab81c28749c9e283726f1a3d6ec6ed90030e6 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 10 Jul 2024 11:20:06 -0400 Subject: [PATCH] Add support for any Python requests (#4948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For roundtrip in #4949 — it should also be fine to request `any` but the user can't construct it right now. --- 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 0b68a8f16..bbdd36471 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())