Fix lockfile generation for shadowed resolves #21642
Open
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.
When a user resolve shadows a tool resolve,
pants generate-lockfiles
will generate the lockfile twice.This is because only the
--request
arg is deduplicated. Without one specified, all known resolves are added to a non-deduplicated collection. The resolves are added separately for each backend andExportableTool
. This can introduce duplicates into this list. And, although the shadowing is correct, the resolve is exported twice. For example, the tool Black and a user resolve named "black" will both use the same resolve name, resulting in a list of resolves to export likeRequestedPythonUserResolveNames(['black', 'python-default', 'coverage-py', 'pytest', 'ipython', 'black'])
.This MR makes 3 adjustments to this process:
RequestedUserResolveNames
is now aDeduplicatedCollection
. This mitigates the most proximate issue of specifying the same resolve.GeneratePythonLockfile
. This may already be covered by 1, but can't hurt[black].install_from_resolve="linters"
, its default resolve "black" will not be exposed.Note that in the case of shadowing without
install_from_resolve
, although the shadowed resolve is not surfaced (for export), Pants will still correctly use the default lockfile.closes #21625