mirror of https://github.com/astral-sh/uv
Allow distributions to be absent in deserialization (#5453)
## Summary Closes https://github.com/astral-sh/uv/issues/5434.
This commit is contained in:
parent
6eb8f85668
commit
75a042d5ff
|
|
@ -571,8 +571,9 @@ impl Lock {
|
|||
#[serde(rename_all = "kebab-case")]
|
||||
struct LockWire {
|
||||
version: u32,
|
||||
#[serde(rename = "distribution")]
|
||||
#[serde(rename = "distribution", default)]
|
||||
distributions: Vec<DistributionWire>,
|
||||
#[serde(default)]
|
||||
requires_python: Option<RequiresPython>,
|
||||
#[serde(default)]
|
||||
resolution_mode: ResolutionMode,
|
||||
|
|
|
|||
|
|
@ -162,3 +162,46 @@ fn frozen() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(
|
||||
r"
|
||||
[tool.uv.workspace]
|
||||
members = []
|
||||
",
|
||||
)?;
|
||||
|
||||
// Running `uv sync` should generate an empty lockfile.
|
||||
uv_snapshot!(context.filters(), context.sync(), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
warning: `uv sync` is experimental and may change without warning
|
||||
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.12`.
|
||||
Resolved 0 packages in [TIME]
|
||||
Audited 0 packages in [TIME]
|
||||
"###);
|
||||
|
||||
assert!(context.temp_dir.child("uv.lock").exists());
|
||||
|
||||
// Running `uv sync` again should succeed.
|
||||
uv_snapshot!(context.filters(), context.sync(), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
warning: `uv sync` is experimental and may change without warning
|
||||
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.12`.
|
||||
Resolved 0 packages in [TIME]
|
||||
Audited 0 packages in [TIME]
|
||||
"###);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue