mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 12:59:45 +00:00
Re-test validity after every lenient parsing change (#2550)
## Summary We had the right fixup for `torchsde`, but a subsequent fixup was making it invalid. In general, we should apply as few of these as we can, so lets stop as soon as we succeed. Closes https://github.com/astral-sh/uv/issues/2546. ## Test Plan `cargo run pip install torchsde==0.2.5 --verbose --reinstall -n --verbose`
This commit is contained in:
parent
2e65092be0
commit
c4107f9c40
1 changed files with 13 additions and 12 deletions
|
|
@ -19,13 +19,13 @@ static INVALID_TRAILING_DOT_STAR: Lazy<Regex> =
|
||||||
static MISSING_DOT: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d\.\d)+\*").unwrap());
|
static MISSING_DOT: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d\.\d)+\*").unwrap());
|
||||||
/// Ex) `>=3.6,`
|
/// Ex) `>=3.6,`
|
||||||
static TRAILING_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(r",\s*$").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#"['"]([*\d])|([*\d])['"]"#).unwrap());
|
|
||||||
/// Ex) `>dev`
|
/// Ex) `>dev`
|
||||||
static GREATER_THAN_DEV: Lazy<Regex> = Lazy::new(|| Regex::new(r">dev").unwrap());
|
static GREATER_THAN_DEV: Lazy<Regex> = Lazy::new(|| Regex::new(r">dev").unwrap());
|
||||||
/// Ex) `>=9.0.0a1.0`
|
/// Ex) `>=9.0.0a1.0`
|
||||||
static TRAILING_ZERO: Lazy<Regex> =
|
static TRAILING_ZERO: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"(\d+(\.\d)*(a|b|rc|post|dev)\d+)\.0").unwrap());
|
Lazy::new(|| Regex::new(r"(\d+(\.\d)*(a|b|rc|post|dev)\d+)\.0").unwrap());
|
||||||
|
/// Ex) `>= '2.7'`, `>=3.6'`
|
||||||
|
static STRAY_QUOTES: Lazy<Regex> = 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
|
||||||
|
|
@ -48,12 +48,12 @@ static FIXUPS: &[(&Lazy<Regex>, &str, &str)] = &[
|
||||||
(&MISSING_DOT, r"${1}.*", "inserting missing dot"),
|
(&MISSING_DOT, r"${1}.*", "inserting missing dot"),
|
||||||
// Given `>=3.6,`, rewrite to `>=3.6`
|
// Given `>=3.6,`, rewrite to `>=3.6`
|
||||||
(&TRAILING_COMMA, r"${1}", "removing trailing comma"),
|
(&TRAILING_COMMA, r"${1}", "removing trailing comma"),
|
||||||
// Given `>= '2.7'`, rewrite to `>= 2.7`
|
|
||||||
(&STRAY_QUOTES, r"$1$2", "removing stray quotes"),
|
|
||||||
// Given `>dev`, rewrite to `>0.0.0dev`
|
// Given `>dev`, rewrite to `>0.0.0dev`
|
||||||
(&GREATER_THAN_DEV, r">0.0.0dev", "assuming 0.0.0dev"),
|
(&GREATER_THAN_DEV, r">0.0.0dev", "assuming 0.0.0dev"),
|
||||||
// Given `>=9.0.0a1.0`, rewrite to `>=9.0.0a1`
|
// Given `>=9.0.0a1.0`, rewrite to `>=9.0.0a1`
|
||||||
(&TRAILING_ZERO, r"${1}", "removing trailing zero"),
|
(&TRAILING_ZERO, r"${1}", "removing trailing zero"),
|
||||||
|
// Given `>= 2.7'`, rewrite to `>= 2.7`
|
||||||
|
(&STRAY_QUOTES, r"$1$2", "removing stray quotes"),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn parse_with_fixups<Err, T: FromStr<Err = Err>>(input: &str, type_name: &str) -> Result<T, Err> {
|
fn parse_with_fixups<Err, T: FromStr<Err = Err>>(input: &str, type_name: &str) -> Result<T, Err> {
|
||||||
|
|
@ -66,18 +66,19 @@ fn parse_with_fixups<Err, T: FromStr<Err = Err>>(input: &str, type_name: &str) -
|
||||||
let patched = matcher.replace_all(patched_input.as_ref(), *replacement);
|
let patched = matcher.replace_all(patched_input.as_ref(), *replacement);
|
||||||
if patched != patched_input {
|
if patched != patched_input {
|
||||||
messages.push(*message);
|
messages.push(*message);
|
||||||
patched_input = patched.to_string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(requirement) = T::from_str(&patched_input) {
|
if let Ok(requirement) = T::from_str(&patched) {
|
||||||
warn!(
|
warn!(
|
||||||
"Fixing invalid {type_name} by {} (before: `{input}`; after: `{patched_input}`)",
|
"Fixing invalid {type_name} by {} (before: `{input}`; after: `{patched}`)",
|
||||||
messages.join(", ")
|
messages.join(", ")
|
||||||
);
|
);
|
||||||
return Ok(requirement);
|
return Ok(requirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patched_input = patched.to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue