Skip to content

Commit

Permalink
Use the proper singular form for workspace member dependencies in res…
Browse files Browse the repository at this point in the history
…olver errors (#6128)
  • Loading branch information
zanieb committed Aug 15, 2024
1 parent db33497 commit fb6b3ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions crates/uv-resolver/src/pubgrub/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,15 @@ impl PackageRange<'_> {
/// be singular or plural e.g. if false use "<range> depends on <...>" and
/// if true use "<range> depend on <...>"
fn plural(&self) -> bool {
// If a workspace member, always use the singular form (otherwise, it'd be "all versions of")
if self
.formatter
.and_then(|formatter| formatter.format_workspace_member(self.package))
.is_some()
{
return false;
}

let mut segments = self.range.iter();
if let Some(segment) = segments.next() {
// A single unbounded compatibility segment is always plural ("all versions of").
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ fn workspace_unsatisfiable_member_dependencies_conflicting_extra() -> Result<()>
----- stderr -----
Using Python 3.12.[X] interpreter at: [PYTHON-3.12]
× No solution found when resolving dependencies:
╰─▶ Because only bar is available and bar depends on anyio==4.2.0, we can conclude that bar depend on anyio==4.2.0.
╰─▶ Because only bar is available and bar depends on anyio==4.2.0, we can conclude that bar depends on anyio==4.2.0.
And because foo depends on anyio==4.1.0, we can conclude that foo and bar are incompatible.
And because your workspace requires bar and foo, we can conclude that your workspace's requirements are unsatisfiable.
"###
Expand Down Expand Up @@ -1440,7 +1440,7 @@ fn workspace_unsatisfiable_member_dependencies_conflicting_dev() -> Result<()> {
----- stderr -----
Using Python 3.12.[X] interpreter at: [PYTHON-3.12]
× No solution found when resolving dependencies:
╰─▶ Because bar depends on bar and bar depends on anyio==4.2.0, we can conclude that bar depend on anyio==4.2.0.
╰─▶ Because bar depends on bar and bar depends on anyio==4.2.0, we can conclude that bar depends on anyio==4.2.0.
And because foo depends on anyio==4.1.0, we can conclude that bar and foo are incompatible.
And because your workspace requires bar and foo, we can conclude that your workspace's requirements are unsatisfiable.
"###
Expand Down

0 comments on commit fb6b3ff

Please sign in to comment.