Skip to content

Commit

Permalink
Merge pull request #9226 from uranusjr/new-resolver-skip-yanked-unles…
Browse files Browse the repository at this point in the history
…s-only

Correctly implement yanking logic
  • Loading branch information
pradyunsg committed Dec 8, 2020
2 parents ab7ff0a + ffb3d1b commit fd8ddb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions news/9203.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
New resolver: Correctly implement PEP 592. Do not return yanked versions from
an index, unless the version range can only be satisfied by yanked candidates.
11 changes: 10 additions & 1 deletion src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,17 @@ def iter_index_candidates():
specifier=specifier,
hashes=hashes,
)
icans = list(result.iter_applicable())

# PEP 592: Yanked releases must be ignored unless only yanked
# releases can satisfy the version range. So if this is false,
# all yanked icans need to be skipped.
all_yanked = all(ican.link.is_yanked for ican in icans)

# PackageFinder returns earlier versions first, so we reverse.
for ican in reversed(list(result.iter_applicable())):
for ican in reversed(icans):
if not all_yanked and ican.link.is_yanked:
continue
yield self._make_candidate_from_link(
link=ican.link,
extras=extras,
Expand Down

0 comments on commit fd8ddb6

Please sign in to comment.