Skip to content

Commit

Permalink
refactor: move logic to get suitable locked package inside _get_locked
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored and abn committed Apr 10, 2022
1 parent 32871e8 commit d34dba7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/poetry/mixology/version_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,7 @@ def _get_min(dependency: Dependency) -> tuple[bool, int]:
return not dependency.marker.is_any(), 1

locked = self._get_locked(dependency)
if locked and (
dependency.constraint.allows(locked.version)
or locked.is_prerelease()
and dependency.constraint.allows(locked.version.next_patch())
):
if locked:
return not dependency.marker.is_any(), 1

# VCS, URL, File or Directory dependencies
Expand All @@ -399,7 +395,7 @@ def _get_min(dependency: Dependency) -> tuple[bool, int]:
dependency = min(*unsatisfied, key=_get_min)

locked = self._get_locked(dependency)
if locked is None or not dependency.constraint.allows(locked.version):
if locked is None:
try:
packages = self._dependency_cache.search_for(dependency)
except ValueError as e:
Expand Down Expand Up @@ -500,6 +496,13 @@ def _get_locked(
if not allow_similar and not dependency.is_same_package_as(locked):
return None

if not (
dependency.constraint.allows(locked.version)
or locked.is_prerelease()
and dependency.constraint.allows(locked.version.next_patch())
):
return None

return locked

def _log(self, text: str) -> None:
Expand Down

0 comments on commit d34dba7

Please sign in to comment.