From 08a7c708d1a20bfd8ebb669e70cb7ee474f3ed1b Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 17 Sep 2024 11:10:38 -0500 Subject: [PATCH] Do not allow local versions in Python version requests either (#7468) Accidentally squashed https://github.com/astral-sh/uv/pull/7465 into the wrong target. --- crates/uv-python/src/discovery.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index ad8d59e69..4ae3f702e 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -1718,8 +1718,8 @@ impl FromStr for VersionRequest { // Split the release component if it uses the wheel tag format (e.g., `38`) let version = split_wheel_tag_release_version(version); - // We dont allow post and dev versions here - if version.post().is_some() || version.dev().is_some() { + // We dont allow post, dev, or local versions here + if version.post().is_some() || version.dev().is_some() || !version.local().is_empty() { return Err(Error::InvalidVersionRequest(s.to_string())); } @@ -2323,6 +2323,13 @@ mod tests { ), "Development version segments are not allowed" ); + assert!( + matches!( + VersionRequest::from_str("3.12+local"), + Err(Error::InvalidVersionRequest(_)) + ), + "Local version segments are not allowed" + ); assert!( matches!( VersionRequest::from_str("3.12.post0"),