Repository navigation
Allow uv upgrade to update multiple declarations of the same package - #20335
Conversation
86a953b to
6526d23
Compare
uv test inventory changesThis PR changes the tests when compared with the
|
| relaxed_requirements | ||
| .iter() | ||
| .map(|(package, dependency_type, existing, replacement)| { | ||
| (package, dependency_type, existing, replacement) |
There was a problem hiding this comment.
It relaxes each selected requirement in a temporary manifest so the resolver can select newer versions. I’ve clarified the comment and replaced the tuple mapping with RequirementUpdate, which also makes the helper input explicit.
LMK if that's clear enough
There was a problem hiding this comment.
I meant on a more low level, why are we having (package, dependency_type, existing, replacement) twice?
| .contains(project.project_name(), extra.as_ref()) | ||
| { | ||
| let package = &selected.package; | ||
| bail!( |
There was a problem hiding this comment.
Do we have a GitHub issue tracking these gaps?
There is a related question where conflicts may put different constraints on a package indirectly, which we should ensure we handle correctly before stabilization.
There was a problem hiding this comment.
I made #20574 for this, but in general I have local changes to address some of these gaps, so I'm hestitant to open issues for all of them (to avoid churn).
There was a problem hiding this comment.
I usually open one tracking issue with checkboxes. That's the easiest way to keep track of all the TODOs in a single place an also supports cross-linking issues and PRs.
| let existing = | ||
| into_verbatim_requirement(selected.requirement.clone(), &selected.package)?; | ||
| let replacement = into_verbatim_requirement(proposed_requirement, &selected.package)?; | ||
| if !updated_requirements |
There was a problem hiding this comment.
How does this check compare to using a BTreeSet?
There was a problem hiding this comment.
How would we use BTreeSet here, I don't think I understand?
There was a problem hiding this comment.
Currently, we're running a manually deduplication check by comparing struct fields. What if updated_requirements was a BTreeSet instead, and we didn't do manual deduplication?
There was a problem hiding this comment.
The problem with a BTreeSet-based deduplication is that we must ignore original_text for dedupe purposes. I've changed this to a BTreeMap instead in f8b39da but I'm not sure it's significantly better tbh
Select upgrade declarations with their effective project marker before validating sources or relaxing the temporary manifest. Reject declarations excluded by the project's Python or environment constraints, since they cannot contribute a resolved version and a partial upgrade would be misleading. Reject current-project conflict-extra declarations before fork attribution, since resolved packages cannot yet be mapped back to those declarations safely.
Carry package and DependencyType through selected declarations and requirement updates while preserving the current production-only selection behavior. Route exact replacements through DependencyType-aware pyproject mutation helpers so later optional, group, and workspace slices can reuse the same one-resolve path. Keep source applicability origin-aware for future declaration kinds, and avoid inspecting unrelated locked packages through registry-specific APIs during attribution.
6526d23 to
0b69abf
Compare
uv upgradecurrently rejects multiple declarations for the same dependency. For example:This updates every matching declaration using the versions resolved for its marker, including exact duplicates, instead of rejecting the upgrade.
Declarations excluded by
requires-pythonor configured environments now fail before resolution, avoiding partial upgrades. Requirement replacement and source validation retain the declaration type so subsequent workspace, optional-dependency, and dependency-group support can reuse the same path.