From 7d6e6fae25ee84c78e7f87728d4eeda19962b7e6 Mon Sep 17 00:00:00 2001 From: konsti Date: Thu, 4 Jan 2024 14:45:41 +0100 Subject: [PATCH] Requirement fixup for trailing comma after trailing quote (#776) Fixup for https://files.pythonhosted.org/packages/74/49/7349527cea7f708e7d3253ab6b32c9b5bdf84a57dde8fc265a33e6a4e662/boto3-1.2.0-py2.py3-none-any.whl: ``` botocore>=1.3.0,<1.4.0', ``` Note that neither the quote nor the comma are right. --- crates/pypi-types/src/lenient_requirement.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/pypi-types/src/lenient_requirement.rs b/crates/pypi-types/src/lenient_requirement.rs index ad019ed90..088a9b18b 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"(\d\.(\d|\*))+,$").unwrap()); +static TRAILING_COMMA: Lazy = Lazy::new(|| Regex::new(r",$").unwrap()); /// Ex) `>= '2.7'`, `>=3.6'` static STRAY_QUOTES: Lazy = Lazy::new(|| Regex::new(r#"['"]"#).unwrap()); @@ -299,4 +299,14 @@ mod tests { let expected: VersionSpecifiers = VersionSpecifiers::from_str(">=3.6").unwrap(); assert_eq!(actual, expected); } + + /// + #[test] + fn trailing_comma_after_quote() { + let actual: Requirement = LenientRequirement::from_str("botocore>=1.3.0,<1.4.0',") + .unwrap() + .into(); + let expected: Requirement = Requirement::from_str("botocore>=1.3.0,<1.4.0").unwrap(); + assert_eq!(actual, expected); + } }