diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index f5e1b78e12723..7d208c2b9ce49 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -629,7 +629,9 @@ impl Lock { }) .filter_map(super::requires_python::SimplifiedMarkerTree::try_to_string), ); - doc.insert("resolution-markers", value(fork_markers)); + if !fork_markers.is_empty() { + doc.insert("resolution-markers", value(fork_markers)); + } } if !self.supported_environments.is_empty() { @@ -1973,7 +1975,7 @@ impl Package { self.id.to_toml(None, &mut table); if !self.fork_markers.is_empty() { - let wheels = each_element_on_its_line_array( + let fork_markers = each_element_on_its_line_array( self.fork_markers .iter() // TODO(ag): Consider whether `resolution-markers` should actually @@ -1983,7 +1985,9 @@ impl Package { .map(|marker| SimplifiedMarkerTree::new(requires_python, marker.pep508())) .filter_map(super::requires_python::SimplifiedMarkerTree::try_to_string), ); - table.insert("resolution-markers", value(wheels)); + if !fork_markers.is_empty() { + table.insert("resolution-markers", value(fork_markers)); + } } if !self.dependencies.is_empty() { diff --git a/crates/uv/tests/it/lock_conflict.rs b/crates/uv/tests/it/lock_conflict.rs index 53619888acf28..8efc9dcee22ad 100644 --- a/crates/uv/tests/it/lock_conflict.rs +++ b/crates/uv/tests/it/lock_conflict.rs @@ -101,8 +101,6 @@ fn extra_basic() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "extra1" }, { package = "project", extra = "extra2" }, @@ -309,8 +307,6 @@ fn extra_basic_three_extras() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "extra1" }, { package = "project", extra = "extra2" }, @@ -824,8 +820,6 @@ fn extra_multiple_independent() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "extra1" }, { package = "project", extra = "extra2" }, @@ -986,8 +980,6 @@ fn extra_config_change_ignore_lockfile() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "extra1" }, { package = "project", extra = "extra2" }, @@ -1499,8 +1491,6 @@ fn group_basic() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "group1" }, { package = "project", group = "group2" }, @@ -1665,8 +1655,6 @@ fn group_default() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "group1" }, { package = "project", group = "group2" }, @@ -1891,8 +1879,6 @@ fn mixed() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "group1" }, { package = "project", extra = "extra1" }, @@ -2067,8 +2053,6 @@ fn multiple_sources_index_disjoint_extras() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "cu118" }, { package = "project", extra = "cu124" }, @@ -2218,8 +2202,6 @@ fn multiple_sources_index_disjoint_groups() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "cu118" }, { package = "project", group = "cu124" }, @@ -2369,8 +2351,6 @@ fn multiple_sources_index_disjoint_extras_with_extra() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "cu118" }, { package = "project", extra = "cu124" }, @@ -2860,8 +2840,6 @@ fn shared_optional_dependency_extra1() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "foo" }, { package = "project", extra = "bar" }, @@ -3004,8 +2982,6 @@ fn shared_optional_dependency_group1() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "foo" }, { package = "project", group = "bar" }, @@ -3150,8 +3126,6 @@ fn shared_optional_dependency_mixed1() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "foo" }, { package = "project", group = "bar" }, @@ -3302,8 +3276,6 @@ fn shared_optional_dependency_extra2() -> Result<()> { lock, @r###" version = 1 requires-python = "==3.11.*" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "foo" }, { package = "project", extra = "bar" }, @@ -3450,8 +3422,6 @@ fn shared_optional_dependency_group2() -> Result<()> { lock, @r###" version = 1 requires-python = "==3.11.*" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "foo" }, { package = "project", group = "bar" }, @@ -3604,8 +3574,6 @@ fn shared_optional_dependency_mixed2() -> Result<()> { lock, @r###" version = 1 requires-python = "==3.11.*" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "foo" }, { package = "project", group = "bar" }, @@ -3752,8 +3720,6 @@ fn shared_dependency_extra() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "foo" }, { package = "project", extra = "bar" }, @@ -3931,8 +3897,6 @@ fn shared_dependency_group() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", group = "foo" }, { package = "project", group = "bar" }, @@ -4112,8 +4076,6 @@ fn shared_dependency_mixed() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "foo" }, { package = "project", group = "bar" }, @@ -4329,8 +4291,6 @@ conflicts = [ lock, @r###" version = 1 requires-python = "==3.11.*" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "x1" }, { package = "proxy1", extra = "x2" }, @@ -4524,8 +4484,6 @@ fn jinja_no_conflict_markers1() -> Result<()> { lock, @r###" version = 1 requires-python = ">=3.12" - resolution-markers = [ - ] conflicts = [[ { package = "project", extra = "cu118" }, { package = "project", extra = "cu124" },