Skip to content

Commit 0104541

Browse files
committed
Avoid subsequent index hint when no versions are available on the first index
1 parent 8149e63 commit 0104541

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

crates/uv-resolver/src/pubgrub/report.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,12 +725,18 @@ impl PubGrubReportFormatter<'_> {
725725
.skip_while(|url| *url != found_index)
726726
.nth(1)
727727
{
728-
hints.insert(PubGrubHint::UncheckedIndex {
729-
package: package.clone(),
730-
range: set.clone(),
731-
found_index: found_index.clone(),
732-
next_index: next_index.clone(),
733-
});
728+
// Do not include the hint if the set is "all versions"
729+
if !set
730+
.iter()
731+
.all(|range| matches!(range, (Bound::Unbounded, Bound::Unbounded)))
732+
{
733+
hints.insert(PubGrubHint::UncheckedIndex {
734+
package: package.clone(),
735+
range: set.clone(),
736+
found_index: found_index.clone(),
737+
next_index: next_index.clone(),
738+
});
739+
}
734740
}
735741
}
736742
}

crates/uv/tests/it/pip_compile.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11659,6 +11659,37 @@ fn compile_index_url_first_match() -> Result<()> {
1165911659
Ok(())
1166011660
}
1166111661

11662+
/// Install a package via `--extra-index-url`.
11663+
///
11664+
/// If the package exists on the "extra" index, but at an incompatible version, the resolution
11665+
/// should fail by default (even though a compatible version exists on the "primary" index).
11666+
#[test]
11667+
fn compile_index_url_first_match_all_versions() -> Result<()> {
11668+
let context = TestContext::new("3.12");
11669+
11670+
let requirements_in = context.temp_dir.child("requirements.in");
11671+
requirements_in.write_str("some-package-not-on-the-index")?;
11672+
11673+
uv_snapshot!(context.filters(), context.pip_compile()
11674+
.arg("--index-url")
11675+
.arg("https://pypi.org/simple")
11676+
.arg("--extra-index-url")
11677+
.arg("https://test.pypi.org/simple")
11678+
.arg("requirements.in")
11679+
.arg("--no-deps"), @r###"
11680+
success: false
11681+
exit_code: 1
11682+
----- stdout -----
11683+
11684+
----- stderr -----
11685+
× No solution found when resolving dependencies:
11686+
╰─▶ Because some-package-not-on-the-index was not found in the package registry and you require some-package-not-on-the-index, we can conclude that your requirements are unsatisfiable.
11687+
"###
11688+
);
11689+
11690+
Ok(())
11691+
}
11692+
1166211693
/// Install a package via `--extra-index-url`.
1166311694
///
1166411695
/// If the package exists exist on the "extra" index, but at an incompatible version, the

0 commit comments

Comments
 (0)