-
Notifications
You must be signed in to change notification settings - Fork 750
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
Conversation
╰─▶ my-project 0a0.dev0 depends on django ∅ | ||
╰─▶ my-project depends on django ∅ |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
DerivationTree::External(external) => { | ||
PuffinExternal::from_pubgrub(external.clone()).to_string() | ||
} |
There was a problem hiding this comment.
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
/// 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) | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Respect
0012594
to
8309a05
Compare
) Partially addresses #310 Addresses case at #309 (comment) Follow-up to #300 ensuring `PuffinExternal` is used consistently when formatting messages Example at https://github.com/astral-sh/puffin/pull/342/files#diff-5c74a74ef34ef1d6e7453de8d2d19134813156e8b6a657e6b5ed71fda5a3a870
Extends #295
Closes #214
Copies some of the implementations from
pubgrub::report
so we can implement PuffinPubGrubPackage
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.