mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-27 18:36:44 +00:00
Use a custom pubgrub report formatter (#521)
Uses https://github.com/zanieb/pubgrub/pull/10 to drastically simplify our reporter implementation. This will allow us to make use of upstream improvements to the reporter e.g. https://github.com/zanieb/pubgrub/pull/8 without multiple duplicative pull requests.
This commit is contained in:
parent
efcc4f1409
commit
2a8544df9e
6 changed files with 74 additions and 419 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::fmt::Formatter;
|
||||
|
||||
use pubgrub::range::Range;
|
||||
use pubgrub::report::Reporter;
|
||||
use pubgrub::report::{DefaultStringReporter, Reporter};
|
||||
use thiserror::Error;
|
||||
use url::Url;
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ use puffin_distribution::DistributionDatabaseError;
|
|||
use puffin_normalize::PackageName;
|
||||
|
||||
use crate::pubgrub::{PubGrubPackage, PubGrubVersion};
|
||||
use crate::ResolutionFailureReporter;
|
||||
use crate::PubGrubReportFormatter;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ResolveError {
|
||||
|
|
@ -78,7 +78,8 @@ impl std::error::Error for RichPubGrubError {}
|
|||
impl std::fmt::Display for RichPubGrubError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
if let pubgrub::error::PubGrubError::NoSolution(derivation_tree) = &self.source {
|
||||
let report = ResolutionFailureReporter::report(derivation_tree);
|
||||
let formatter = PubGrubReportFormatter;
|
||||
let report = DefaultStringReporter::report_with_formatter(derivation_tree, &formatter);
|
||||
write!(f, "{report}")
|
||||
} else {
|
||||
write!(f, "{}", self.source)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue