Skip to content

Commit

Permalink
Fix fallback when no release can be found
Browse files Browse the repository at this point in the history
Specifier.filter() returns an iterator, so we need to evaluate it...
  • Loading branch information
uranusjr committed Sep 2, 2018
1 parent 44cb236 commit 73f0f95
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/passa/internals/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _requirement_from_metadata(name, version, extras, index):
return r


def find_candidates(requirement, sources, allow_pre):
def find_candidates(requirement, sources, allow_prereleases):
# A non-named requirement has exactly one candidate that is itself. For
# VCS, we also lock the requirement to an exact ref.
if not requirement.is_named:
Expand All @@ -68,14 +68,18 @@ def find_candidates(requirement, sources, allow_pre):
))
icans = matching_icans or icans

versions = ireq.specifier.filter((c.version for c in icans), allow_pre)
if not allow_pre and not versions:
versions = ireq.specifier.filter((c.version for c in icans), True)
versions = sorted(ireq.specifier.filter(
(c.version for c in icans), allow_prereleases,
))
if not allow_prereleases and not versions:
versions = sorted(ireq.specifier.filter(
(c.version for c in icans), True,
))

name = requirement.normalized_name
extras = requirement.extras
index = requirement.index
return [
_requirement_from_metadata(name, version, extras, index)
for version in sorted(versions)
for version in versions
]

0 comments on commit 73f0f95

Please sign in to comment.