Skip to content

Commit

Permalink
Move yanked link warning into the legacy resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Apr 24, 2020
1 parent cdc9954 commit 5cb135b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
16 changes: 0 additions & 16 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,23 +556,7 @@ def sort_best_candidate(
"""
if not candidates:
return None

best_candidate = max(candidates, key=self._sort_key)

# Log a warning per PEP 592 if necessary before returning.
link = best_candidate.link
if link.is_yanked:
reason = link.yanked_reason or '<none given>'
msg = (
# Mark this as a unicode string to prevent
# "UnicodeEncodeError: 'ascii' codec can't encode character"
# in Python 2 when the reason contains non-ascii characters.
u'The candidate selected for download or install is a '
'yanked version: {candidate}\n'
'Reason for being yanked: {reason}'
).format(candidate=best_candidate, reason=reason)
logger.warning(msg)

return best_candidate

def compute_best_candidate(
Expand Down
17 changes: 16 additions & 1 deletion src/pip/_internal/resolution/legacy/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,22 @@ def _find_requirement_link(self, req):
best_candidate = self.finder.find_requirement(req, upgrade)
if not best_candidate:
return None
return best_candidate.link

# Log a warning per PEP 592 if necessary before returning.
link = best_candidate.link
if link.is_yanked:
reason = link.yanked_reason or '<none given>'
msg = (
# Mark this as a unicode string to prevent
# "UnicodeEncodeError: 'ascii' codec can't encode character"
# in Python 2 when the reason contains non-ascii characters.
u'The candidate selected for download or install is a '
'yanked version: {candidate}\n'
'Reason for being yanked: {reason}'
).format(candidate=best_candidate, reason=reason)
logger.warning(msg)

return link

def _populate_link(self, req):
# type: (InstallRequirement) -> None
Expand Down

0 comments on commit 5cb135b

Please sign in to comment.