Add fixup for invalid double quotes (#663)

Closes https://github.com/astral-sh/puffin/issues/658.
This commit is contained in:
Charlie Marsh 2023-12-15 13:11:22 -05:00 committed by GitHub
parent 9470c20e7a
commit 47290f784e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,7 +20,7 @@ static MISSING_DOT: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d\.\d)+\*").unwrap
static TRAILING_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d\.(\d|\*))+,$").unwrap()); static TRAILING_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d\.(\d|\*))+,$").unwrap());
/// Ex) `>= '2.7'` /// Ex) `>= '2.7'`
static INVALID_QUOTES: Lazy<Regex> = static INVALID_QUOTES: Lazy<Regex> =
Lazy::new(|| Regex::new(r"((?:~=|==|!=|<=|>=|<|>|===) )*'(\d(?:\.\d)*)'").unwrap()); Lazy::new(|| Regex::new(r#"((?:~=|==|!=|<=|>=|<|>|===) )*['"](\d(?:\.\d)*)['"]"#).unwrap());
/// Regex to match the invalid specifier, replacement to fix it and message about was wrong and /// Regex to match the invalid specifier, replacement to fix it and message about was wrong and
/// fixed /// fixed
@ -239,7 +239,7 @@ mod tests {
/// <https://pypi.org/simple/shellingham/?format=application/vnd.pypi.simple.v1+json> /// <https://pypi.org/simple/shellingham/?format=application/vnd.pypi.simple.v1+json>
#[test] #[test]
fn specifier_invalid_quotes() { fn specifier_invalid_single_quotes() {
let actual: VersionSpecifiers = LenientVersionSpecifiers::from_str(">= '2.7'") let actual: VersionSpecifiers = LenientVersionSpecifiers::from_str(">= '2.7'")
.unwrap() .unwrap()
.into(); .into();
@ -247,6 +247,16 @@ mod tests {
assert_eq!(actual, expected); assert_eq!(actual, expected);
} }
/// <https://pypi.org/simple/tensorflowonspark/?format=application/vnd.pypi.simple.v1+json>
#[test]
fn specifier_invalid_double_quotes() {
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/celery/?format=application/vnd.pypi.simple.v1+json> /// <https://pypi.org/simple/celery/?format=application/vnd.pypi.simple.v1+json>
#[test] #[test]
fn specifier_multi_fix() { fn specifier_multi_fix() {