Skip to content

Commit

Permalink
Reduce the size of the ConflictingVersions err variant
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Nov 14, 2023
1 parent 8e4f468 commit ada2226
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ info:
- pip-compile
- pyproject.toml
- "--cache-dir"
- /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmpvGljPp
- /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmpJ9Dkj3
env:
VIRTUAL_ENV: /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmp2rBXR2/.venv
VIRTUAL_ENV: /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmpBOyFGn/.venv
---
success: false
exit_code: 1
----- stdout -----

----- stderr -----
× No solution found when resolving dependencies:
╰─▶ my-project dependencies are unusable: `django==5.0b1` does not intersect
with `django==5.0a1`
╰─▶ my-project dependencies are unusable: Conflicting versions for `django`:
`django==5.0b1` does not intersect with `django==5.0a1`

4 changes: 2 additions & 2 deletions crates/puffin-resolver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub enum ResolveError {
#[error("Conflicting URLs for package `{0}`: {1} and {2}")]
ConflictingUrls(PackageName, String, String),

#[error("`{0}{1}` does not intersect with `{0}{2}`")]
ConflictingVersions(PubGrubPackage, Range<PubGrubVersion>, Range<PubGrubVersion>),
#[error("Conflicting versions for `{0}`: {1}")]
ConflictingVersions(String, String),

#[error("Package `{0}` attempted to resolve via URL: {1}. URL dependencies must be expressed as direct requirements or constraints. Consider adding `{0} @ {1}` to your dependencies or constraints file.")]
DisallowedUrl(PackageName, Url),
Expand Down
5 changes: 2 additions & 3 deletions crates/puffin-resolver/src/pubgrub/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ fn merge_versions(
let result = left.intersection(right);
if result.is_empty() {
Err(ResolveError::ConflictingVersions(
package.clone(),
left.clone(),
right.clone(),
package.to_string(),
format!("`{package}{left}` does not intersect with `{package}{right}`"),
))
} else {
Ok(result)
Expand Down
1 change: 0 additions & 1 deletion crates/puffin-resolver/src/pubgrub/report.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::fmt;

use pubgrub::package::Package;
use pubgrub::range::Range;
use pubgrub::report::{DerivationTree, Derived, External, Reporter};
use pubgrub::term::Term;
Expand Down
2 changes: 1 addition & 1 deletion crates/puffin-resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
self.markers,
);
if let Err(err @ ResolveError::ConflictingVersions(..)) = constraints {
return Ok(Dependencies::Unusable(Some(format!("{err}"))));
return Ok(Dependencies::Unusable(Some(err.to_string())));
}
let constraints = constraints?;

Expand Down

0 comments on commit ada2226

Please sign in to comment.