Skip to content

Commit

Permalink
Allow distributions to be absent in deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 25, 2024
1 parent 4da34a6 commit 58ed6ff
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
43 changes: 43 additions & 0 deletions crates/uv/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 58ed6ff

Please sign in to comment.