From f7b8d7bd6b33715ee94340f319a5ad78d24c0679 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 7 Dec 2024 23:39:17 -0500 Subject: [PATCH] Show workspcace in hint --- crates/uv-resolver/src/pubgrub/report.rs | 28 ++++++++++++++++++------ crates/uv/tests/it/lock.rs | 10 ++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/crates/uv-resolver/src/pubgrub/report.rs b/crates/uv-resolver/src/pubgrub/report.rs index 3d5d5e2f5664..74d86bc0c072 100644 --- a/crates/uv-resolver/src/pubgrub/report.rs +++ b/crates/uv-resolver/src/pubgrub/report.rs @@ -617,7 +617,8 @@ impl PubGrubReportFormatter<'_> { && workspace_members.contains(package_name) { output_hints.insert(PubGrubHint::DependsOnItself { - package: package.clone(), + package: package_name.clone(), + workspace: self.is_workspace() && !self.is_single_project_workspace(), }); } } @@ -950,9 +951,12 @@ pub(crate) enum PubGrubHint { workspace: bool, }, /// A package depends on itself at an incompatible version. - DependsOnItself { package: PubGrubPackage }, + DependsOnItself { + package: PackageName, + workspace: bool, + }, /// A package was available on an index, but not at the correct version, and at least one - /// subsequent index was not queried. As such, a compatible version may be available on an + /// subsequent index was not queried. As such, a compatible version may be available on /// one of the remaining indexes. UncheckedIndex { package: PubGrubPackage, @@ -1016,7 +1020,8 @@ enum PubGrubHintCore { workspace: bool, }, DependsOnItself { - package: PubGrubPackage, + package: PackageName, + workspace: bool, }, UncheckedIndex { package: PubGrubPackage, @@ -1082,7 +1087,9 @@ impl From for PubGrubHintCore { dependency, workspace, }, - PubGrubHint::DependsOnItself { package } => Self::DependsOnItself { package }, + PubGrubHint::DependsOnItself { package, workspace } => { + Self::DependsOnItself { package, workspace } + } PubGrubHint::UncheckedIndex { package, .. } => Self::UncheckedIndex { package }, PubGrubHint::UnauthorizedIndex { index } => Self::UnauthorizedIndex { index }, PubGrubHint::ForbiddenIndex { index } => Self::ForbiddenIndex { index }, @@ -1325,13 +1332,20 @@ impl std::fmt::Display for PubGrubHint { dependency.cyan(), ) } - Self::DependsOnItself { package } => { + Self::DependsOnItself { package, workspace } => { + let project = if *workspace { + "workspace member" + } else { + "project" + }; write!( f, - "{}{} The package `{}` depends on itself at an incompatible version. This is likely a mistake. Consider removing the dependency.", + "{}{} The {project} `{}` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `{}`, consider renaming the {project} `{}` to avoid creating a conflict.", "hint".bold().cyan(), ":".bold(), package.cyan(), + package.cyan(), + package.cyan(), ) } Self::UncheckedIndex { diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index 38c5e8900780..c2735aa26cf5 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -19457,7 +19457,7 @@ fn lock_self_incompatible() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because your project depends on itself at an incompatible version (project==0.2.0), we can conclude that your project's requirements are unsatisfiable. - hint: The package `project` depends on itself at an incompatible version. This is likely a mistake. Consider removing the dependency. + hint: The project `project` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `project`, consider renaming the project `project` to avoid creating a conflict. "###); Ok(()) @@ -19592,7 +19592,7 @@ fn lock_self_extra_to_same_extra_incompatible() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because project[foo] depends on your project and your project requires project[foo], we can conclude that your project's requirements are unsatisfiable. - hint: The package `project[foo]` depends on itself at an incompatible version. This is likely a mistake. Consider removing the dependency. + hint: The project `project` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `project`, consider renaming the project `project` to avoid creating a conflict. "###); Ok(()) @@ -19626,7 +19626,7 @@ fn lock_self_extra_to_other_extra_incompatible() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because project[foo] depends on your project and your project requires project[foo], we can conclude that your project's requirements are unsatisfiable. - hint: The package `project[foo]` depends on itself at an incompatible version. This is likely a mistake. Consider removing the dependency. + hint: The project `project` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `project`, consider renaming the project `project` to avoid creating a conflict. "###); Ok(()) @@ -19761,7 +19761,7 @@ fn lock_self_extra_incompatible() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because project[foo] depends on your project and your project requires project[foo], we can conclude that your project's requirements are unsatisfiable. - hint: The package `project[foo]` depends on itself at an incompatible version. This is likely a mistake. Consider removing the dependency. + hint: The project `project` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `project`, consider renaming the project `project` to avoid creating a conflict. "###); Ok(()) @@ -19890,7 +19890,7 @@ fn lock_self_marker_incompatible() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because only project{sys_platform == 'win32'}<=0.1 is available and your project depends on project{sys_platform == 'win32'}>0.1, we can conclude that your project's requirements are unsatisfiable. - hint: The package `project` depends on itself at an incompatible version. This is likely a mistake. Consider removing the dependency. + hint: The project `project` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `project`, consider renaming the project `project` to avoid creating a conflict. "###); Ok(())