Skip to content

Commit

Permalink
Add hints
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Dec 7, 2024
1 parent 52b10c6 commit decf6cd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/uv-resolver/src/pubgrub/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,16 @@ impl PubGrubReportFormatter<'_> {
workspace: self.is_workspace() && !self.is_single_project_workspace(),
});
}

if package_name == dependency_name
&& (dependency.extra().is_none() || package.extra() == dependency.extra())
&& (dependency.dev().is_none() || dependency.dev() == package.dev())
&& workspace_members.contains(package_name)
{
output_hints.insert(PubGrubHint::DependsOnItself {
package: package.clone(),
});
}
}
// Check for no versions due to `Requires-Python`.
if matches!(
Expand Down Expand Up @@ -939,6 +949,8 @@ pub(crate) enum PubGrubHint {
dependency: PubGrubPackage,
workspace: bool,
},
/// A package depends on itself at an incompatible version.
DependsOnItself { package: PubGrubPackage },
/// 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
/// one of the remaining indexes.
Expand Down Expand Up @@ -1003,6 +1015,9 @@ enum PubGrubHintCore {
dependency: PubGrubPackage,
workspace: bool,
},
DependsOnItself {
package: PubGrubPackage,
},
UncheckedIndex {
package: PubGrubPackage,
},
Expand Down Expand Up @@ -1067,6 +1082,7 @@ impl From<PubGrubHint> for PubGrubHintCore {
dependency,
workspace,
},
PubGrubHint::DependsOnItself { package } => Self::DependsOnItself { package },
PubGrubHint::UncheckedIndex { package, .. } => Self::UncheckedIndex { package },
PubGrubHint::UnauthorizedIndex { index } => Self::UnauthorizedIndex { index },
PubGrubHint::ForbiddenIndex { index } => Self::ForbiddenIndex { index },
Expand Down Expand Up @@ -1309,6 +1325,15 @@ impl std::fmt::Display for PubGrubHint {
dependency.cyan(),
)
}
Self::DependsOnItself { package } => {
write!(
f,
"{}{} The package `{}` depends on itself. This is likely a mistake. Consider removing the dependency.",
"hint".bold().cyan(),
":".bold(),
package.cyan(),
)
}
Self::UncheckedIndex {
package,
range,
Expand Down
6 changes: 6 additions & 0 deletions crates/uv/tests/it/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19253,6 +19253,8 @@ fn lock_self_incompatible() -> Result<()> {
----- stderr -----
× 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. This is likely a mistake. Consider removing the dependency.
"###);

Ok(())
Expand Down Expand Up @@ -19391,6 +19393,8 @@ fn lock_self_extra_incompatible() -> Result<()> {
----- stderr -----
× 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. This is likely a mistake. Consider removing the dependency.
"###);

Ok(())
Expand Down Expand Up @@ -19519,6 +19523,8 @@ fn lock_self_marker_incompatible() -> Result<()> {
----- stderr -----
× 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. This is likely a mistake. Consider removing the dependency.
"###);

Ok(())
Expand Down

0 comments on commit decf6cd

Please sign in to comment.