-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add PackageFinder.make_candidate_evaluator() #6687
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
Conversation
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.
Have we considered going the direction of the caller passing in a CandidateEvaluator factory instead of bundled preferences/options used by PackageFinder itself to instantiate CandidateEvaluator(s)? We would still get to the eventual goal of per-requirement CandidateEvaluator objects, and at the same time reduce some of the boilerplate related to translating arguments between different structures.
@classmethod | ||
def create( | ||
cls, | ||
target_python=None, # type: Optional[TargetPython] |
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.
Out of curiosity, what is the style convention for the offset of these type declaration comments? In some places it is aligned with the others in a declaration, in others there are chunks of aligned comments, and in others they are all just 2 spaces from their corresponding parameters.
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.
I don't know of one. I've always been accustomed to two spaces for inline comments, but some people started aligning them. I think it's overboard to always align (e.g. having to change every argument line just because of a change in one line), so I sometimes align to adjacent lines when convenient and it improves the readability / how it looks.
071b99d
to
4a9e306
Compare
For now I just wanted to keep things unclever while also keeping things flexible and not making changes that would require unneeded changes to test code. I did briefly consider |
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.
Thanks for the review and helpful comments, @chrahunt! |
(Merging this now so I can work on the follow-on PR.) |
This is a follow-on to the refactoring in PR #6684.
The main thing this PR does is add a
make_candidate_evaluator()
method to thePackageFinder
class to parallel themake_link_evaluator()
method. This sets things up to allow for per-requirementCandidateEvaluator
objects, which will be useful for later PR's.This PR also does the following related things:
CandidatePreferences
class to encapsulate most of the options needed forCandidateEvaluator
. (A later PR can add a parallelLinkPreferences
class forLinkEvaluator
.) Both of these will help to cut down the number of arguments / attributes needed for thePackageFinder
class. It also helps the reader to conceptualize what "package-finding" stage the various options / attributes are needed for.CandidateEvaluator.make_found_candidates()
a separately testableCandidateEvaluator.get_applicable_candidates()
method. This isolates to one method the logic for filtering the "non-applicable" candidates out from the list of all candidates. This PR also adds a unit test of this method.