Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/uv-pypi-types/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,23 @@ impl Conflicts {
///
/// A `TryFrom<Vec<ConflictItem>>` impl may be used to build a set from a
/// sequence. Note though that at least 2 items are required.
#[derive(Debug, Default, Clone, Hash, Eq, PartialEq)]
#[derive(Debug, Default, Clone, Hash)]
pub struct ConflictSet {
set: BTreeSet<ConflictItem>,
/// Whether this conflict set was inferred from transitively included items.
///
/// Note this field is _not_ included in equality checks.
is_inferred_conflict: bool,
}

impl PartialEq for ConflictSet {
fn eq(&self, other: &Self) -> bool {
self.set == other.set
}
}

impl Eq for ConflictSet {}

impl ConflictSet {
/// Create a pair of items that conflict with one another.
pub fn pair(item1: ConflictItem, item2: ConflictItem) -> Self {
Expand Down
20 changes: 19 additions & 1 deletion crates/uv/tests/it/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10986,6 +10986,24 @@ fn transitive_group_conflicts_shallow() -> Result<()> {
"#,
)?;

uv_snapshot!(context.filters(), context.lock(), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved 5 packages in [TIME]
");

uv_snapshot!(context.filters(), context.lock().arg("--check"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved 5 packages in [TIME]
");
Comment on lines +10998 to +11005
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see the failure from the issue in 44522f0


uv_snapshot!(context.filters(), context.sync(), @r"
success: true
exit_code: 0
Expand Down Expand Up @@ -11037,7 +11055,7 @@ fn transitive_group_conflicts_shallow() -> Result<()> {

----- stderr -----
Resolved 5 packages in [TIME]
error: Groups `dev` and `magic` are incompatible with the transitively inferred conflicts: {`example:dev`, `example:magic`}
error: Groups `dev` and `magic` are incompatible with the declared conflicts: {`example:dev`, `example:magic`}
Comment on lines 11057 to +11058
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this regresses the error message, I'll need to investigate that further.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably the problem is that we're installing from the lockfile instead of a fresh resolution, which drops this information.

I think there are a few options here

  1. Read the pyproject.toml to determine if the conflict is transitive
  2. Change the encoding in the lockfile to avoid flattening nested groups
  3. Add a marker to the lockfile to indicate a transitive conflict is present
  4. Drop this special-case entirely

I sort of argue for (4), while we might want (2) or (3) in the future, they seem like a fair bit of work and the improvement in the error message is quite minor.

");

Ok(())
Expand Down
Loading