Merge pull request #9226 from uranusjr/new-resolver-skip-yanked-unless-only

Correctly implement yanking logic
This commit is contained in:
Pradyun Gedam 2020-12-08 06:14:57 +00:00 committed by GitHub
commit fd8ddb6e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

2
news/9203.bugfix.rst Normal file
View File

@ -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.

View File

@ -193,8 +193,17 @@ class Factory(object):
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,