Consolidate locked dependency selection APIs - #19982
#19982Merged
zsol merged 2 commits intoJun 26, 2026
mainastral-sh/uv:mainfrom
zsol/uv-lock-dependency-selection-api-v2astral-sh/uv:zsol/uv-lock-dependency-selection-api-v2Copy head branch name to clipboard
Merged
Consolidate locked dependency selection APIs#19982zsol merged 2 commits intomainastral-sh/uv:mainfrom zsol/uv-lock-dependency-selection-api-v2astral-sh/uv:zsol/uv-lock-dependency-selection-api-v2Copy head branch name to clipboard
zsol merged 2 commits into
mainastral-sh/uv:mainfrom
zsol/uv-lock-dependency-selection-api-v2astral-sh/uv:zsol/uv-lock-dependency-selection-api-v2Copy head branch name to clipboard
Conversation
uv test inventory changesThis PR changes the tests when compared with the latest
|
zsol
marked this pull request as ready for review
June 25, 2026 08:25
zanieb
reviewed
Jun 25, 2026
zsol
force-pushed
the
zsol/uv-lock-dependency-selection-api-v2
branch
from
June 25, 2026 14:52
71fa7bd to
7db8448
Compare
zanieb
reviewed
Jun 26, 2026
zanieb
approved these changes
Jun 26, 2026
zanieb
left a comment
Member
There was a problem hiding this comment.
I still think something is a little off here but think I'd have to poke at it myself to give constructive feedback — seems like a nice improvement.
Member
Author
If/when you do get to this, let me know. Happy to own following up, and am interested in how this can be improved - seems like an important API going forward |
zsol
force-pushed
the
zsol/uv-lock-dependency-selection-api-v2
branch
from
June 26, 2026 13:20
2ce9c30 to
b332bc1
Compare
zsol
enabled auto-merge (squash)
June 26, 2026 13:21
zsol
added a commit
that referenced
this pull request
Jun 26, 2026
`uv check --script` currently ignores a direct `ty` dependency from PEP 723 metadata when choosing the checker. The script environment contains the locked package, but uv still selects a standalone `ty` from its built-in compatible range, so the checker can differ from the script’s dependency graph. This extends `Lock::dependency_selection` to include applicable lock-manifest requirements. When a script directly declares `ty`, `uv check` now runs the marker-selected locked package from the script environment, preserving its source and transitive dependencies without another resolution. This is a followup to #19884 and it depends on #19982.
zsol
added a commit
that referenced
this pull request
Jul 9, 2026
…#20078) `Lock::dependency_selection` selects the exact locked package for a direct project dependency, but the result currently discards information, like selected extras or dependency-group conflict context (used to select conflict forks). This isn't critical for our current use cases (ruff and ty), but it's worth fixing to avoid future confusion. For a relatively contrived example, a workspace may use a local build of `ty` that depends on `a`, with two mutually exclusive groups pinning `a==1` and `a==2`. With `uv check --no-sync`, uv selects the correct locked `ty` for the enabled group, but previously discarded that group context when building the cached environment. The marker on `ty`’s dependency still referred to the project conflict outside the synthetic tool subgraph, so materialization failed instead of selecting the corresponding `a` fork. This PR returns a `SelectedDependency` containing the exact package, the union of extras from applicable direct edges, and the production or dependency-group context. `Lock::to_resolution_from_dependency` passes that information into the existing locked-subgraph traversal, activating selected extras and resolving project conflict items even though the project itself is outside the cached subgraph. This is a follow-up to #19982 and #19989.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
project::toolchaincurrently uses three separateLockAPIs to select a preferred dependency-group package, fall back to a production dependency, and determine whether the exact package is already selected by the enabled groups. This spreads one query across the resolver and command code and can discover the same locked package more than once.This replaces those methods with
Lock::dependency_selection, which resolves the production and dependency-group packages for a marker environment once. The returnedDependencySelectionsupports direct production and group lookups and iteration over group selections. Any ambiguity encountered while materializing the selection fails the operation.This is a followup to #19884