Skip to content

Commit

Permalink
Only allow yanked releases on version pins
Browse files Browse the repository at this point in the history
TODO: add/update tests?
  • Loading branch information
Jackenmen committed Jul 30, 2021
1 parent 310c9ad commit e9d1555
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,21 @@ def iter_index_candidate_infos() -> Iterator[IndexCandidateInfo]:
)
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,
# PEP 592: Yanked releases must be ignored if the version range
# can be satisfied with non-yanked version. So if this is false,
# all yanked icans need to be skipped.
# If this is true, PEP recommends ignoring the yanked releases
# unless the version is pinned to an exact version with ==/===.
all_yanked = all(ican.link.is_yanked for ican in icans)
version_pinned = any(
spec.operator == "==="
or (spec.operator == "==" and not spec.version.endswith(".*"))
for spec in specifier
)

# PackageFinder returns earlier versions first, so we reverse.
for ican in reversed(icans):
if not all_yanked and ican.link.is_yanked:
if not (all_yanked and version_pinned) and ican.link.is_yanked:
continue
func = functools.partial(
self._make_candidate_from_link,
Expand Down

0 comments on commit e9d1555

Please sign in to comment.