mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-20 11:56:03 +00:00
Don't warn when dependency is constraint by other dependency (#16149)
Currently, `uv lock --resolution lowest-direct` warns above the setup
below, as we visit the unbounded `anyio[trio]` first.
```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"anyio[trio]",
"anyio>=4"
]
```
This commit is contained in:
parent
252f887338
commit
73e62c0c17
2 changed files with 55 additions and 6 deletions
|
|
@ -2938,15 +2938,33 @@ impl ForkState {
|
||||||
resolution_strategy,
|
resolution_strategy,
|
||||||
ResolutionStrategy::Lowest | ResolutionStrategy::LowestDirect(..)
|
ResolutionStrategy::Lowest | ResolutionStrategy::LowestDirect(..)
|
||||||
);
|
);
|
||||||
|
|
||||||
if !has_url && missing_lower_bound && strategy_lowest {
|
if !has_url && missing_lower_bound && strategy_lowest {
|
||||||
|
let name = package.name_no_root().unwrap();
|
||||||
|
// Handle cases where a package is listed both without and with a lower bound.
|
||||||
|
// Example:
|
||||||
|
// ```
|
||||||
|
// "coverage[toml] ; python_version < '3.11'",
|
||||||
|
// "coverage >= 7.10.0",
|
||||||
|
// ```
|
||||||
|
let bound_on_other_package = dependencies.iter().any(|other| {
|
||||||
|
Some(name) == other.package.name()
|
||||||
|
&& !other
|
||||||
|
.version
|
||||||
|
.bounding_range()
|
||||||
|
.map(|(lowest, _highest)| lowest == Bound::Unbounded)
|
||||||
|
.unwrap_or(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
if !bound_on_other_package {
|
||||||
warn_user_once!(
|
warn_user_once!(
|
||||||
"The direct dependency `{name}` is unpinned. \
|
"The direct dependency `{name}` is unpinned. \
|
||||||
Consider setting a lower bound when using `--resolution lowest` \
|
Consider setting a lower bound when using `--resolution lowest` \
|
||||||
or `--resolution lowest-direct` to avoid using outdated versions.",
|
or `--resolution lowest-direct` to avoid using outdated versions.",
|
||||||
name = package.name_no_root().unwrap(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the package priorities.
|
// Update the package priorities.
|
||||||
self.priorities.insert(package, version, &self.fork_urls);
|
self.priorities.insert(package, version, &self.fork_urls);
|
||||||
|
|
|
||||||
|
|
@ -31969,3 +31969,34 @@ fn collapsed_error_with_marker_packages() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <https://github.com/astral-sh/uv/issues/16148>
|
||||||
|
#[test]
|
||||||
|
fn no_warning_without_and_with_lower_bound() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
|
||||||
|
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||||
|
pyproject_toml.write_str(
|
||||||
|
r#"
|
||||||
|
[project]
|
||||||
|
name = "project"
|
||||||
|
version = "0.1.0"
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
dependencies = [
|
||||||
|
"anyio[trio]",
|
||||||
|
"anyio>=4"
|
||||||
|
]
|
||||||
|
"#,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.filters(), context.lock().arg("--resolution").arg("lowest-direct"), @r"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 10 packages in [TIME]
|
||||||
|
");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue