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

Simplify FoundCandidates #6684

Merged
merged 2 commits into from
Jul 6, 2019
Merged

Conversation

cjerdonek
Copy link
Member

@cjerdonek cjerdonek commented Jul 6, 2019

This PR simplifies the FoundCandidates class by moving the calculation logic in FoundCandidates.iter_applicable() into the make_found_candidates() function that creates a FoundCandidates object.

This makes it so FoundCandidates behaves more like a simple container. It also makes it so that the determination of applicable candidates happens just once when the FoundCandidates object is created, instead of each time one wants to iterate over the applicable candidates.

This PR also adds the first test of the make_found_candidates() method.

This PR will come in handy for some later PR's.

@cjerdonek cjerdonek added C: finder PackageFinder and index related code skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code labels Jul 6, 2019
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.

Me likey.

@cjerdonek
Copy link
Member Author

Thanks!

@cjerdonek cjerdonek merged commit 9311049 into pypa:master Jul 6, 2019
@cjerdonek cjerdonek deleted the simplify-found-candidates branch July 6, 2019 09:04
self._candidates = candidates
self._evaluator = evaluator
self._versions = versions
Copy link
Member

Choose a reason for hiding this comment

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

Late nit: I'd put an assert set(self._applicable_candidates) <= set(self._candidates) to make sure args are coherent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for taking a look, @xavfernandez. I'll do this in a future PR.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Aug 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: finder PackageFinder and index related code skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants