Skip to content

Commit aad2d1d

Browse files
committed
Repurpose backtracking hook
See discussion at pypa/pip#10937.
1 parent ebf6c51 commit aad2d1d

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/resolvelib/reporters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def resolving_conflicts(self, causes):
3636
:param causes: The information on the collision that caused the backtracking.
3737
"""
3838

39-
def backtracking(self, candidate):
39+
def backtracking(self, criterion, candidate):
4040
"""Called when rejecting a candidate during backtracking."""
4141

4242
def pinning(self, candidate):

src/resolvelib/reporters.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class BaseReporter:
66
def ending_round(self, index: int, state: Any) -> Any: ...
77
def ending(self, state: Any) -> Any: ...
88
def adding_requirement(self, requirement: Any, parent: Any) -> Any: ...
9-
def backtracking(self, candidate: Any) -> Any: ...
9+
def backtracking(self, criterion: Any, candidate: Any) -> Any: ...
1010
def resolving_conflicts(self, causes: Any) -> Any: ...
1111
def pinning(self, candidate: Any) -> Any: ...

src/resolvelib/resolvers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def _attempt_to_pin_criterion(self, name):
212212
try:
213213
criteria = self._get_updated_criteria(candidate)
214214
except RequirementsConflicted as e:
215+
self._r.backtracking(e.criterion, candidate)
215216
causes.append(e.criterion)
216217
continue
217218

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

284-
self._r.backtracking(candidate=candidate)
285-
286285
# Create a new state from the last known-to-work one, and apply
287286
# the previously gathered incompatibility information.
288287
def _patch_criteria():

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TestReporter(BaseReporter):
99
def __init__(self):
1010
self._indent = 0
1111

12-
def backtracking(self, candidate):
12+
def backtracking(self, criterion, candidate):
1313
self._indent -= 1
1414
assert self._indent >= 0
1515
print(" " * self._indent, "Back ", candidate, sep="")

0 commit comments

Comments
 (0)