mirror of https://github.com/astral-sh/uv
Allow owned string when deserializing `requires-python` (#12278)
## Summary I suspect this only affects packages with quotes in the requires-python, which is typically an error but one that we correct for in `LenientVersionSpecifiers`. Closes https://github.com/astral-sh/uv/issues/12260.
This commit is contained in:
parent
e0f81f0d4a
commit
b78f9291fe
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use jiff::Timestamp;
|
use jiff::Timestamp;
|
||||||
|
|
@ -86,9 +87,11 @@ impl<'de> Deserialize<'de> for File {
|
||||||
"filename" => filename = Some(access.next_value()?),
|
"filename" => filename = Some(access.next_value()?),
|
||||||
"hashes" => hashes = Some(access.next_value()?),
|
"hashes" => hashes = Some(access.next_value()?),
|
||||||
"requires-python" => {
|
"requires-python" => {
|
||||||
requires_python = access.next_value::<Option<&str>>()?.map(|s| {
|
requires_python =
|
||||||
LenientVersionSpecifiers::from_str(s).map(VersionSpecifiers::from)
|
access.next_value::<Option<Cow<'_, str>>>()?.map(|s| {
|
||||||
});
|
LenientVersionSpecifiers::from_str(s.as_ref())
|
||||||
|
.map(VersionSpecifiers::from)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
"size" => size = Some(access.next_value()?),
|
"size" => size = Some(access.next_value()?),
|
||||||
"upload-time" => upload_time = Some(access.next_value()?),
|
"upload-time" => upload_time = Some(access.next_value()?),
|
||||||
|
|
|
||||||
|
|
@ -16129,3 +16129,44 @@ fn respect_non_local_preference() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// See: <https://github.com/astral-sh/uv/issues/12260>
|
||||||
|
#[test]
|
||||||
|
fn compile_quotes() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
let requirements_in = context.temp_dir.child("requirements.in");
|
||||||
|
requirements_in.write_str("tbump")?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.filters(), windows_filters=false, context.pip_compile()
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--universal"), @r"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
# This file was autogenerated by uv via the following command:
|
||||||
|
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --universal
|
||||||
|
cli-ui==0.17.2
|
||||||
|
# via tbump
|
||||||
|
colorama==0.4.6
|
||||||
|
# via cli-ui
|
||||||
|
contextlib2==21.6.0
|
||||||
|
# via schema
|
||||||
|
docopt==0.6.2
|
||||||
|
# via tbump
|
||||||
|
schema==0.7.5
|
||||||
|
# via tbump
|
||||||
|
tabulate==0.8.10
|
||||||
|
# via cli-ui
|
||||||
|
tbump==6.11.0
|
||||||
|
# via -r requirements.in
|
||||||
|
tomlkit==0.11.8
|
||||||
|
# via tbump
|
||||||
|
unidecode==1.3.8
|
||||||
|
# via cli-ui
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 9 packages in [TIME]
|
||||||
|
");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue