From fb6b3ff410bc5b37890d61732fa8cc5263753a5c Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 15 Aug 2024 16:08:41 -0500 Subject: [PATCH] Use the proper singular form for workspace member dependencies in resolver errors (#6128) --- crates/uv-resolver/src/pubgrub/report.rs | 9 +++++++++ crates/uv/tests/workspace.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/uv-resolver/src/pubgrub/report.rs b/crates/uv-resolver/src/pubgrub/report.rs index cdc031849d67..8a0f832aaa69 100644 --- a/crates/uv-resolver/src/pubgrub/report.rs +++ b/crates/uv-resolver/src/pubgrub/report.rs @@ -1058,6 +1058,15 @@ impl PackageRange<'_> { /// be singular or plural e.g. if false use " depends on <...>" and /// if true use " 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"). diff --git a/crates/uv/tests/workspace.rs b/crates/uv/tests/workspace.rs index 2ef70f1b9d80..12ae15116a3e 100644 --- a/crates/uv/tests/workspace.rs +++ b/crates/uv/tests/workspace.rs @@ -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. "### @@ -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. "###