From 7994b686541f337585a7a85d2952c6547bc43bf9 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 15 Feb 2024 21:08:05 -0500 Subject: [PATCH] Add fix-up for trailing comma with trailing space (#1409) ## Summary Closes https://github.com/astral-sh/uv/issues/1361. ## Test Plan ```text Resolved 3 packages in 243ms Downloaded 3 packages in 193ms Installed 3 packages in 6ms + et-xmlfile==1.1.0 + jdcal==1.4.1 + openpyxl==3.0.5 ``` --- crates/pypi-types/src/lenient_requirement.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/pypi-types/src/lenient_requirement.rs b/crates/pypi-types/src/lenient_requirement.rs index 88c9a7c13..e74642414 100644 --- a/crates/pypi-types/src/lenient_requirement.rs +++ b/crates/pypi-types/src/lenient_requirement.rs @@ -18,7 +18,7 @@ static INVALID_TRAILING_DOT_STAR: Lazy = /// Ex) `!=3.0*` static MISSING_DOT: Lazy = Lazy::new(|| Regex::new(r"(\d\.\d)+\*").unwrap()); /// Ex) `>=3.6,` -static TRAILING_COMMA: Lazy = Lazy::new(|| Regex::new(r",$").unwrap()); +static TRAILING_COMMA: Lazy = Lazy::new(|| Regex::new(r",\s*$").unwrap()); /// Ex) `>= '2.7'`, `>=3.6'` static STRAY_QUOTES: Lazy = Lazy::new(|| Regex::new(r#"['"]"#).unwrap()); @@ -237,6 +237,15 @@ mod tests { assert_eq!(actual, expected); } + #[test] + fn specifier_trailing_comma_trailing_space() { + let actual: VersionSpecifiers = LenientVersionSpecifiers::from_str(">=3.6, ") + .unwrap() + .into(); + let expected: VersionSpecifiers = VersionSpecifiers::from_str(">=3.6").unwrap(); + assert_eq!(actual, expected); + } + /// #[test] fn specifier_invalid_single_quotes() {