Improve error messages when there are no versions of a singleton range (#855)

This commit is contained in:
Zanie Blue 2024-01-09 15:09:52 -06:00 committed by GitHub
parent 33982efb25
commit 34d548de21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -1405,7 +1405,7 @@ fn conflicting_direct_url_dependency() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there are no versions of werkzeug==3.0.0 and root depends on
Because there is no version of werkzeug==3.0.0 and root depends on
werkzeug==3.0.0, version solving failed.
"###);
});
@ -1899,8 +1899,8 @@ dependencies = ["django==300.1.4"]
----- stderr -----
× No solution found when resolving dependencies:
Because there are no versions of django==300.1.4 and my-project depends
on django==300.1.4, version solving failed.
Because there is no version of django==300.1.4 and my-project depends on
django==300.1.4, version solving failed.
"###);
});

View file

@ -1271,7 +1271,7 @@ fn requires_transitive_prerelease_and_stable_dependency() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there are no versions of c==2.0.0b1 and a==1.0.0 depends on c==2.0.0b1, a==1.0.0 is forbidden.
Because there is no version of c==2.0.0b1 and a==1.0.0 depends on c==2.0.0b1, a==1.0.0 is forbidden.
And because there are no versions of a<1.0.0 | >1.0.0 and root depends on a, version solving failed.
hint: c was requested with a pre-release marker (e.g., ==2.0.0b1), but pre-releases weren't enabled (try: `--prerelease=allow`)
@ -1681,7 +1681,7 @@ fn requires_exact_version_does_not_exist() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there are no versions of a==2.0.0 and root depends on a==2.0.0, version solving failed.
Because there is no version of a==2.0.0 and root depends on a==2.0.0, version solving failed.
"###);
});
@ -2315,7 +2315,7 @@ fn requires_python_version_greater_than_current_many() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there are no versions of a==1.0.0 and root depends on a==1.0.0, version solving failed.
Because there is no version of a==1.0.0 and root depends on a==1.0.0, version solving failed.
"###);
});

View file

@ -34,6 +34,8 @@ impl ReportFormatter<PubGrubPackage, Range<PubGrubVersion>> for PubGrubReportFor
let set = self.simplify_set(set, package);
if set.as_ref() == &Range::full() {
format!("there are no versions of {package}")
} else if set.as_singleton().is_some() {
format!("there is no version of {package}{set}")
} else {
format!("there are no versions of {package}{set}")
}