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
```
This commit is contained in:
Charlie Marsh 2024-02-15 21:08:05 -05:00 committed by GitHub
parent 0f554b0913
commit 7994b68654
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,7 +18,7 @@ static INVALID_TRAILING_DOT_STAR: Lazy<Regex> =
/// Ex) `!=3.0*`
static MISSING_DOT: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d\.\d)+\*").unwrap());
/// Ex) `>=3.6,`
static TRAILING_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(r",$").unwrap());
static TRAILING_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(r",\s*$").unwrap());
/// Ex) `>= '2.7'`, `>=3.6'`
static STRAY_QUOTES: Lazy<Regex> = 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);
}
/// <https://pypi.org/simple/shellingham/?format=application/vnd.pypi.simple.v1+json>
#[test]
fn specifier_invalid_single_quotes() {