From ae7a2cddc24345f396d98cbf0e6cc62beaa72f6d Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 19 Jan 2024 11:07:14 -0600 Subject: [PATCH] Avoid showing negations of ranges in error messages (#981) Closes https://github.com/astral-sh/puffin/issues/980 --- crates/puffin-resolver/src/pubgrub/report.rs | 6 +++++- crates/puffin/tests/pip_install_scenarios.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/puffin-resolver/src/pubgrub/report.rs b/crates/puffin-resolver/src/pubgrub/report.rs index b9281e3c1af6..d9f648ca02e0 100644 --- a/crates/puffin-resolver/src/pubgrub/report.rs +++ b/crates/puffin-resolver/src/pubgrub/report.rs @@ -433,7 +433,11 @@ impl std::fmt::Display for PackageTerm<'_> { let package = self.package; write!(f, "{package}!={version}") } else { - write!(f, "!( {} )", PackageRange::compatibility(self.package, set)) + write!( + f, + "{}", + PackageRange::compatibility(self.package, &set.complement()) + ) } } } diff --git a/crates/puffin/tests/pip_install_scenarios.rs b/crates/puffin/tests/pip_install_scenarios.rs index 8757223ee0d6..ba37ade68f9c 100644 --- a/crates/puffin/tests/pip_install_scenarios.rs +++ b/crates/puffin/tests/pip_install_scenarios.rs @@ -695,10 +695,10 @@ fn dependency_excludes_non_contiguous_range_of_compatible_versions() -> Result<( albatross>1.0.0,<2.0.0 we can conclude that albatross<2.0.0 depends on bluebird==1.0.0. And because we know from (1) that crow<2.0.0 depends on albatross<2.0.0, we can conclude that crow<2.0.0 depends on bluebird==1.0.0. - And because crow==2.0.0 depends on albatross>=3.0.0 we can conclude that all versions of crow, bluebird!=1.0.0, !( albatross>=3.0.0 ) are incompatible. (2) + And because crow==2.0.0 depends on albatross>=3.0.0 we can conclude that all versions of crow, bluebird!=1.0.0, albatross<3.0.0 are incompatible. (2) Because albatross==3.0.0 depends on bluebird==3.0.0 and only albatross<=3.0.0 is available, we can conclude that albatross>=3.0.0 depends on bluebird==3.0.0. - And because we know from (2) that all versions of crow, bluebird!=1.0.0, !( albatross>=3.0.0 ) are incompatible, we can conclude that all versions of crow depend on one of: + And because we know from (2) that all versions of crow, bluebird!=1.0.0, albatross<3.0.0 are incompatible, we can conclude that all versions of crow depend on one of: bluebird<=1.0.0 bluebird>=3.0.0