Skip to content
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

Resolve direct and pinned requirements first #9211

Merged
merged 2 commits into from
Dec 3, 2020

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Dec 3, 2020

Close #9185.

@uranusjr uranusjr added the type: enhancement Improvements to functionality label Dec 3, 2020
@uranusjr uranusjr added this to the 20.3.1 milestone Dec 3, 2020
Copy link
Member

@pfmoore pfmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure how _get_restrictive_rating implements the order of preference described. That's mainly because I don't really understand what get_candidate_lookup does, though, so it's not directly an issue with this PR.

We should maybe add a documentation comment for get_candidate_lookup, and explain a bit better how it links to the preference calculation here, but that can easily be a followup (it's definitely not the worst documented bit of code in pip!)

@uranusjr
Copy link
Member Author

uranusjr commented Dec 3, 2020

We should maybe add a documentation comment for get_candidate_lookup, and explain a bit better how it links to the preference calculation here

Good idea, added!

@pfmoore
Copy link
Member

pfmoore commented Dec 3, 2020

Good idea, added!

Awesome :-)

Switching to an explicit check rather than using is_pinned makes it more understandable too. And I don't think it hurts maintainability as the reason we're checking for equality conditions is different here.

The subtle difference between is_pinned and the explicit check for == is "fun" 🙂 I didn't look up is_pinned on my first review, which was part of my confusion (my bad) but it wouldn't prioritise >1.0,==2.0 where the new check does. It's times like these when I think we have too much flexibility...

@uranusjr
Copy link
Member Author

uranusjr commented Dec 3, 2020

The subtle difference between is_pinned and the explicit check for == is "fun" 🙂

This in turn prompted me to search the code base for is_pinned usages. It turns out it is used exactly once:

# Unpinned packages are asking for trouble when a new version
# is uploaded. This isn't a security check, but it saves users
# a surprising hash mismatch in the future.
# file:/// URLs aren't pinnable, so don't complain about them
# not being pinned.
if req.original_link is None and not req.is_pinned:
raise HashUnpinned()

And I… have doubts if the implementation is correct.

@pfmoore
Copy link
Member

pfmoore commented Dec 3, 2020

And I… have doubts if the implementation is correct.

Yeah, that looks weird. This is why I tend to leave the hash-checking code to people who use/need the feature (and therefore presumably understand the requirements 😉)

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One "I'd really like to wrap this up in one go" suggestion: #9211 (comment)

Other than that, this looks great!

@pradyunsg
Copy link
Member

Linters aren't happy, but happy to merge once that's fixed.

@pradyunsg pradyunsg merged commit ab7ff0a into pypa:master Dec 3, 2020
@uranusjr uranusjr deleted the new-resolver-pinned-first branch December 3, 2020 13:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New resolver: Try == specifiers first to catch simple incompatibilities faster
3 participants