Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom resolution failure reporter to hide root package versions #300

Merged
merged 3 commits into from
Nov 3, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Nov 2, 2023

Extends #295
Closes #214

Copies some of the implementations from pubgrub::report so we can implement Puffin PubGrubPackage specific display when explaining failed resolutions.

Here, we just drop the dummy version number if it's a PubGrubPackage::Root package. In the future, we can further customize reporting.

@zanieb zanieb changed the base branch from main to zanie/root-name November 2, 2023 21:25
╰─▶ my-project 0a0.dev0 depends on django ∅
╰─▶ my-project depends on django ∅
Copy link
Member Author

Choose a reason for hiding this comment

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

At what cost... :D

lines: Vec<String>,
}

impl ResolutionFailureReporter {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is all copied without change

Comment on lines +312 to +314
DerivationTree::External(external) => {
PuffinExternal::from_pubgrub(external.clone()).to_string()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Here, we change from external.to_string() to use our internal type

Comment on lines +324 to +357
/// Puffin derivative of [`pubgrub::report::External`] for customized display
/// for Puffin internal [`PubGrubPackage`].
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone)]
enum PuffinExternal {
/// Initial incompatibility aiming at picking the root package for the first decision.
NotRoot(PubGrubPackage, PubGrubVersion),
/// There are no versions in the given set for this package.
NoVersions(PubGrubPackage, Range<PubGrubVersion>),
/// Dependencies of the package are unavailable for versions in that set.
UnavailableDependencies(PubGrubPackage, Range<PubGrubVersion>),
/// Incompatibility coming from the dependencies of a given package.
FromDependencyOf(
PubGrubPackage,
Range<PubGrubVersion>,
PubGrubPackage,
Range<PubGrubVersion>,
),
}

impl PuffinExternal {
fn from_pubgrub(external: External<PubGrubPackage, Range<PubGrubVersion>>) -> Self {
match external {
External::NotRoot(p, v) => PuffinExternal::NotRoot(p, v),
External::NoVersions(p, vs) => PuffinExternal::NoVersions(p, vs),
External::UnavailableDependencies(p, vs) => {
PuffinExternal::UnavailableDependencies(p, vs)
}
External::FromDependencyOf(p, vs, p_dep, vs_dep) => {
PuffinExternal::FromDependencyOf(p, vs, p_dep, vs_dep)
}
}
}
}
Copy link
Member Author

@zanieb zanieb Nov 2, 2023

Choose a reason for hiding this comment

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

Here, we replicate the entire External type so we can impl fmt::Display

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Respect

Base automatically changed from zanie/root-name to main November 3, 2023 15:22
@zanieb zanieb marked this pull request as ready for review November 3, 2023 15:24
@zanieb zanieb merged commit addcfe5 into main Nov 3, 2023
3 checks passed
@zanieb zanieb deleted the zanie/root-version branch November 3, 2023 15:47
zanieb added a commit that referenced this pull request Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error messages involving "root" package
2 participants