mirror of https://github.com/pypa/pip
Sort applicable candidates before computing best candidate (#7332)
This commit is contained in:
commit
6c04feff1d
|
@ -187,12 +187,11 @@ user, and other user preferences, etc.
|
|||
|
||||
Specifically, the class has a ``get_applicable_candidates()`` method.
|
||||
This accepts the ``InstallationCandidate`` objects resulting from the links
|
||||
accepted by the ``LinkEvaluator`` class's ``evaluate_link()`` method, and
|
||||
it further filters them to a list of "applicable" candidates.
|
||||
accepted by the ``LinkEvaluator`` class's ``evaluate_link()`` method, filters
|
||||
them to a list of "applicable" candidates and orders them by preference.
|
||||
|
||||
The ``CandidateEvaluator`` class also has a ``sort_best_candidate()`` method
|
||||
that orders the applicable candidates by preference, and then returns the
|
||||
best (i.e. most preferred).
|
||||
that returns the best (i.e. most preferred) candidate.
|
||||
|
||||
Finally, the class has a ``compute_best_candidate()`` method that calls
|
||||
``get_applicable_candidates()`` followed by ``sort_best_candidate()``, and
|
||||
|
|
|
@ -474,12 +474,14 @@ class CandidateEvaluator(object):
|
|||
c for c in candidates if str(c.version) in versions
|
||||
]
|
||||
|
||||
return filter_unallowed_hashes(
|
||||
filtered_applicable_candidates = filter_unallowed_hashes(
|
||||
candidates=applicable_candidates,
|
||||
hashes=self._hashes,
|
||||
project_name=self._project_name,
|
||||
)
|
||||
|
||||
return sorted(filtered_applicable_candidates, key=self._sort_key)
|
||||
|
||||
def _sort_key(self, candidate):
|
||||
# type: (InstallationCandidate) -> CandidateSortingKey
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue