-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Resolver: Always return an install candidate last (i.e. most preferred) if matches #8014
New Resolver: Always return an install candidate last (i.e. most preferred) if matches #8014
Conversation
This rewrites how a SpecifierRequirement generates candidates, so it * Always return an AlreadyInstalledCandidate (as long as the version satisfies the specifier), even if PackageFinder does not return a candidate for the same version. * Always put the AlreadyInstalledCandidate last, so it's preferred over LinkCandidate, preventing version changes if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, but this LGTM!
if not should_use_installed_dist: | ||
return self._make_candidate_from_link( | ||
for ican in found.iter_applicable(): | ||
if dist is not None and dist.parsed_version == ican.version: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe rename dist
as installed_dist
- the point of this check wasn't obvious to me when the name is just dist
. I think just renaming the variable would make that check clearer. Or you could add a comment :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
This rewrites how a SpecifierRequirement generates candidates, so it
AlreadyInstalledCandidate
(as long as the version satisfies the specifier), even ifPackageFinder
does not return a candidate for the same version.AlreadyInstalledCandidate
last, so it’s preferred overLinkCandidate
, preventing version changes if possible.