From d10ac453840e6184ecd2f582cee9d13e93fd0883 Mon Sep 17 00:00:00 2001 From: Zanie Date: Wed, 10 Jan 2024 11:09:08 -0600 Subject: [PATCH] Restore space in version range segments with intersections --- .../puffin-cli/tests/pip_install_scenarios.rs | 36 +++++++++---------- crates/puffin-resolver/src/pubgrub/report.rs | 9 ++--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/crates/puffin-cli/tests/pip_install_scenarios.rs b/crates/puffin-cli/tests/pip_install_scenarios.rs index 2bd24f467..4686dabbe 100644 --- a/crates/puffin-cli/tests/pip_install_scenarios.rs +++ b/crates/puffin-cli/tests/pip_install_scenarios.rs @@ -158,8 +158,8 @@ fn excluded_only_compatible_version() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because there are no versions of a that satisfy any of: a<1.0.0 - a>1.0.0,<2.0.0 - a>2.0.0,<3.0.0 + a>1.0.0, <2.0.0 + a>2.0.0, <3.0.0 a>3.0.0 and a==1.0.0 depends on b==1.0.0, we can conclude that a<2.0.0 depends on b==1.0.0. And because a==3.0.0 depends on b==3.0.0 we can conclude that any of: @@ -280,13 +280,13 @@ fn dependency_excludes_range_of_compatible_versions() -> Result<()> { × No solution found when resolving dependencies: ╰─▶ Because there are no versions of a that satisfy any of: a<1.0.0 - a>1.0.0,<2.0.0 + a>1.0.0, <2.0.0 a>3.0.0 and a==1.0.0 depends on b==1.0.0, we can conclude that a<2.0.0 depends on b==1.0.0. (1) Because there are no versions of c that satisfy any of: c<1.0.0 - c>1.0.0,<2.0.0 + c>1.0.0, <2.0.0 c>2.0.0 and c==1.0.0 depends on a<2.0.0, we can conclude that c<2.0.0 depends on a<2.0.0. And because c==2.0.0 depends on a>=3.0.0 we can conclude that c depends on one of: @@ -422,7 +422,7 @@ fn dependency_excludes_non_contiguous_range_of_compatible_versions() -> Result<( × No solution found when resolving dependencies: ╰─▶ Because a==1.0.0 depends on b==1.0.0 and there are no versions of a that satisfy any of: a<1.0.0 - a>1.0.0,<2.0.0 + a>1.0.0, <2.0.0 a>3.0.0 we can conclude that a<2.0.0 depends on b==1.0.0. And because a==3.0.0 depends on b==3.0.0 we can conclude that any of: @@ -435,7 +435,7 @@ fn dependency_excludes_non_contiguous_range_of_compatible_versions() -> Result<( Because there are no versions of c that satisfy any of: c<1.0.0 - c>1.0.0,<2.0.0 + c>1.0.0, <2.0.0 c>2.0.0 and c==1.0.0 depends on a<2.0.0, we can conclude that c<2.0.0 depends on a<2.0.0. And because c==2.0.0 depends on a>=3.0.0 we can conclude that c depends on one of: @@ -1640,13 +1640,13 @@ fn requires_transitive_prerelease_and_stable_dependency_many_versions_holes() -> ----- stderr ----- × No solution found when resolving dependencies: ╰─▶ Because there are no versions of c that satisfy any of: - c>1.0.0,<2.0.0a5 - c>2.0.0a7,<2.0.0b1 - c>2.0.0b1,<2.0.0b5 + c>1.0.0, <2.0.0a5 + c>2.0.0a7, <2.0.0b1 + c>2.0.0b1, <2.0.0b5 and a==1.0.0 depends on one of: - c>1.0.0,<2.0.0a5 - c>2.0.0a7,<2.0.0b1 - c>2.0.0b1,<2.0.0b5 + c>1.0.0, <2.0.0a5 + c>2.0.0a7, <2.0.0b1 + c>2.0.0b1, <2.0.0b5 we can conclude that a==1.0.0 is forbidden. And because there are no versions of a that satisfy any of: a<1.0.0 @@ -1654,9 +1654,9 @@ fn requires_transitive_prerelease_and_stable_dependency_many_versions_holes() -> and root depends on a, we can conclude that the requirements are unsatisfiable. hint: c was requested with a pre-release marker (e.g., any of: - c>1.0.0,<2.0.0a5 - c>2.0.0a7,<2.0.0b1 - c>2.0.0b1,<2.0.0b5 + c>1.0.0, <2.0.0a5 + c>2.0.0a7, <2.0.0b1 + c>2.0.0b1, <2.0.0b5 ), but pre-releases weren't enabled (try: `--prerelease=allow`) "###); }); @@ -2548,13 +2548,13 @@ fn requires_python_version_greater_than_current_excluded() -> Result<()> { ----- stderr ----- × No solution found when resolving dependencies: ╰─▶ Because there are no versions of Python that satisfy Python>=3.10,<3.11 and there are no versions of Python that satisfy Python>=3.12, we can conclude that any of: - Python>=3.10,<3.11 + Python>=3.10, <3.11 Python>=3.12 are incompatible. And because there are no versions of Python that satisfy Python>=3.11,<3.12 we can conclude that Python>=3.10 are incompatible. And because a==2.0.0 depends on Python>=3.10 and there are no versions of a that satisfy any of: - a>2.0.0,<3.0.0 - a>3.0.0,<4.0.0 + a>2.0.0, <3.0.0 + a>3.0.0, <4.0.0 a>4.0.0 we can conclude that a>=2.0.0,<3.0.0 is forbidden. (1) diff --git a/crates/puffin-resolver/src/pubgrub/report.rs b/crates/puffin-resolver/src/pubgrub/report.rs index a708c099f..bf85246d6 100644 --- a/crates/puffin-resolver/src/pubgrub/report.rs +++ b/crates/puffin-resolver/src/pubgrub/report.rs @@ -481,6 +481,7 @@ impl std::fmt::Display for PackageRange<'_> { PackageRangeKind::Requires => write!(f, "any of:")?, } } + let space = if segments.len() > 1 { " " } else { "" }; for segment in &segments { if segments.len() > 1 { write!(f, "\n ")?; @@ -495,13 +496,13 @@ impl std::fmt::Display for PackageRange<'_> { if v == b { write!(f, "=={v}")?; } else { - write!(f, ">={v},<={b}")?; + write!(f, ">={v},{space}<={b}")?; } } - (Bound::Included(v), Bound::Excluded(b)) => write!(f, ">={v},<{b}")?, + (Bound::Included(v), Bound::Excluded(b)) => write!(f, ">={v},{space}<{b}")?, (Bound::Excluded(v), Bound::Unbounded) => write!(f, ">{v}")?, - (Bound::Excluded(v), Bound::Included(b)) => write!(f, ">{v},<={b}")?, - (Bound::Excluded(v), Bound::Excluded(b)) => write!(f, ">{v},<{b}")?, + (Bound::Excluded(v), Bound::Included(b)) => write!(f, ">{v},{space}<={b}")?, + (Bound::Excluded(v), Bound::Excluded(b)) => write!(f, ">{v},{space}<{b}")?, }; } if segments.len() > 1 {