-
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
Add support for "yanked" files (PEP 592) #6647
Conversation
4f19fbb
to
b632242
Compare
b632242
to
49a4f05
Compare
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.
Wohoo! @cjerdonek Thanks for picking this up! :D
I'd prefer if we model this a little differently -- part of this is from the PoV that when we do have backtracking resolution, we'd want an order of preference, rather than just a single choice as returned currently. CandidateEvaluator
/ FoundCandidates
are a perfect model for that as it stands IMO, so I'd like to keep it that way. :)
We should filter the items in case of allow_yanked=False
, in iter_applicable()
. In _sort_key
, we should move yanked releases to the end of the sorted list. That way, get_best_candidate
can change to return sorted_candidates[0]
/ None
if no candidates match -- or go back to max
.
Yes, this splits the responsibility of handling yanked releases, across two classes but I feel that is justified since CandidateEvaluator
should only hold the logic for "which is best" and FoundCandidates
should hold the logic for "which are allowed/OK".
Thoughts welcome as always. :)
aside: About the sorted call in get_best_candidate -- As it stands, I'd figured it's easy to modify it to simply expose the sorted list of candidates from CandidateEvaluator
, instead of the best candidate. The backtracking resolver will want a sequence of candidates by order of preference, so if we're making the change of storing the sorted list and then "choosing" the best, it'd probably be worthwhile to put the "sort this candidate list" in a method that we can start adding tests for it eagerly. I'm okay to defer that to later and go back to the max
call for now (there's no hurry and it'd be a good task for new contributors too FWIW).
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.
Nice and clear as usual 👍
Maybe a more functional test could be added with a fake index (something like https://github.com/pypa/pip/tree/master/tests/data/indexes)
+1 I don't say this often enough -- your PRs are super smooth to review @cjerdonek! :D |
👍 I did not like the need to sort the whole list but could not figure a clean way to do that 🤦♂️ .
It crossed my mind, but was uncomfortable with the fact that |
Awesome suggestion! Thanks for pointing that out. My mind was thinking of a related PR, so I missed that way of thinking about it. |
49a4f05
to
b100607
Compare
Thanks, @pradyunsg and @xavfernandez for the great suggestions and quick reviews. I just pushed an updated PR that I think incorporates all of your suggestions. I also think the PR and tests have become simpler due to @pradyunsg's suggestion on sorting vs. filtering. The only thing missing is a more functional / end-to-end test as @xavfernandez suggested, but I can start thinking about how to do that. |
b100607
to
a447be4
Compare
Since @xavfernandez and @pradyunsg both approved this, and because the other approach / refactor we started discussing (re: filtering out yanked files earlier in the |
Sounds good to me! :) |
Thanks again, @pradyunsg and @xavfernandez for your good suggestions and reviews! |
Just a minor process thing -- it'd be great if you could file issues for the follow ups to be made here, the end-to-end test as well as the filtering discussion! :) Thanks for doing this @cjerdonek! |
Yay! :)
With the power of re-reading, a minor clarification: this = this PR; not the issues. But, but, but thanks for making them @cjerdonek! Much appreciated! :) |
Fixes #6633.