Skip to content

Commit

Permalink
simplify implementation
Browse files Browse the repository at this point in the history
Only the provider find_matches() method really needs to be changed.

Signed-off-by: Doug Hellmann <[email protected]>
  • Loading branch information
dhellmann committed Apr 22, 2020
1 parent e7a44f3 commit 6e74053
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/pip/_internal/resolution/resolvelib/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ def get_preference(
information # type: Sequence[Tuple[Requirement, Candidate]]
):
# type: (...) -> Any
if self._prefer_minimum_versions:
return 0
return len(candidates)

def find_matches(self, requirement):
# type: (Requirement) -> Sequence[Candidate]
return requirement.find_matches()
results = requirement.find_matches()
if self._prefer_minimum_versions:
results = list(reversed(results))
return results

def is_satisfied_by(self, requirement, candidate):
# type: (Requirement, Candidate) -> bool
Expand Down
6 changes: 1 addition & 5 deletions src/pip/_vendor/resolvelib/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ def _get_criteria_to_update(self, candidate):

def _attempt_to_pin_criterion(self, name, criterion, prefer_minimum_versions):
causes = []
if prefer_minimum_versions:
candidates_in_order = criterion.candidates
else:
candidates_in_order = reversed(criterion.candidates)
for candidate in candidates_in_order:
for candidate in reversed(criterion.candidates):
try:
criteria = self._get_criteria_to_update(candidate)
except RequirementsConflicted as e:
Expand Down

0 comments on commit 6e74053

Please sign in to comment.