Skip to content

Commit

Permalink
Repurpose backtracking hook
Browse files Browse the repository at this point in the history
See discussion at pypa/pip#10937.
  • Loading branch information
astrojuanlu committed Mar 4, 2022
1 parent ebf6c51 commit c947214
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/resolvelib/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def resolving_conflicts(self, causes):
:param causes: The information on the collision that caused the backtracking.
"""

def backtracking(self, candidate):
def backtracking(self, criterion, candidate):
"""Called when rejecting a candidate during backtracking."""

def pinning(self, candidate):
Expand Down
2 changes: 1 addition & 1 deletion src/resolvelib/reporters.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class BaseReporter:
def ending_round(self, index: int, state: Any) -> Any: ...
def ending(self, state: Any) -> Any: ...
def adding_requirement(self, requirement: Any, parent: Any) -> Any: ...
def backtracking(self, candidate: Any) -> Any: ...
def backtracking(self, criterion: Any, candidate: Any) -> Any: ...
def resolving_conflicts(self, causes: Any) -> Any: ...
def pinning(self, candidate: Any) -> Any: ...
3 changes: 1 addition & 2 deletions src/resolvelib/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def _attempt_to_pin_criterion(self, name):
try:
criteria = self._get_updated_criteria(candidate)
except RequirementsConflicted as e:
self._r.backtracking(e.criterion, candidate)
causes.append(e.criterion)
continue

Expand Down Expand Up @@ -281,8 +282,6 @@ def _backtrack(self):
# Also mark the newly known incompatibility.
incompatibilities_from_broken.append((name, [candidate]))

self._r.backtracking(candidate=candidate)

# Create a new state from the last known-to-work one, and apply
# the previously gathered incompatibility information.
def _patch_criteria():
Expand Down

0 comments on commit c947214

Please sign in to comment.