diff --git a/src/pip/_internal/resolution/resolvelib/reporter.py b/src/pip/_internal/resolution/resolvelib/reporter.py index bc136515a98..cc1c27c5e40 100644 --- a/src/pip/_internal/resolution/resolvelib/reporter.py +++ b/src/pip/_internal/resolution/resolvelib/reporter.py @@ -1,8 +1,8 @@ -from collections import defaultdict from logging import getLogger -from typing import Any, DefaultDict +from typing import Any from pip._vendor.resolvelib.reporters import BaseReporter +from pip._vendor.resolvelib.resolvers import Criterion from .base import Candidate, Requirement @@ -10,29 +10,9 @@ class PipReporter(BaseReporter): - def __init__(self) -> None: - self.backtracks_by_package: DefaultDict[str, int] = defaultdict(int) - - self._messages_at_backtrack = { - 1: ( - "pip is looking at multiple versions of {package_name} to " - "determine which version is compatible with other " - "requirements. This could take a while." - ), - 8: ( - "pip is looking at multiple versions of {package_name} to " - "determine which version is compatible with other " - "requirements. This could take a while." - ), - 13: ( - "This is taking longer than usual. You might need to provide " - "the dependency resolver with stricter constraints to reduce " - "runtime. See https://pip.pypa.io/warnings/backtracking for " - "guidance. If you want to abort this run, press Ctrl + C." - ), - } - - def discarding_conflicted_criterion(self, criterion, candidate) -> None: + def backtracking( + self, criterion: Criterion[Any, Any, Any], candidate: Candidate + ) -> None: msg = "Will try a different candidate, due to conflict:" for req_info in criterion.information: req, parent = req_info.requirement, req_info.parent @@ -43,17 +23,8 @@ def discarding_conflicted_criterion(self, criterion, candidate) -> None: else: msg += "The user requested " msg += req.format_for_error() - logger.info(msg) - - def backtracking(self, candidate: Candidate) -> None: - self.backtracks_by_package[candidate.name] += 1 - - count = self.backtracks_by_package[candidate.name] - if count not in self._messages_at_backtrack: - return - message = self._messages_at_backtrack[count] - logger.info("INFO: %s", message.format(package_name=candidate.name)) + logger.info("INFO: %s", msg) class PipDebuggingReporter(BaseReporter): @@ -74,7 +45,9 @@ def ending(self, state: Any) -> None: def adding_requirement(self, requirement: Requirement, parent: Candidate) -> None: logger.info("Reporter.adding_requirement(%r, %r)", requirement, parent) - def backtracking(self, candidate: Candidate) -> None: + def backtracking( + self, criterion: Criterion[Any, Any, Any], candidate: Candidate + ) -> None: logger.info("Reporter.backtracking(%r)", candidate) def pinning(self, candidate: Candidate) -> None: diff --git a/src/pip/_vendor/resolvelib/reporters.py b/src/pip/_vendor/resolvelib/reporters.py index c20734ab55c..092905bc19f 100644 --- a/src/pip/_vendor/resolvelib/reporters.py +++ b/src/pip/_vendor/resolvelib/reporters.py @@ -30,16 +30,13 @@ def adding_requirement(self, requirement, parent): requirements passed in from ``Resolver.resolve()``. """ - def discarding_conflicted_criterion(self, criterion, candidate): - """Called when discarding conflicted requirements.""" - def resolving_conflicts(self, causes): """Called when starting to attempt requirement conflict resolution. :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): diff --git a/src/pip/_vendor/resolvelib/reporters.pyi b/src/pip/_vendor/resolvelib/reporters.pyi index 03d4f09a390..6eff65cb8b3 100644 --- a/src/pip/_vendor/resolvelib/reporters.pyi +++ b/src/pip/_vendor/resolvelib/reporters.pyi @@ -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: ... diff --git a/src/pip/_vendor/resolvelib/resolvers.py b/src/pip/_vendor/resolvelib/resolvers.py index 7fed25bea99..d072e110df5 100644 --- a/src/pip/_vendor/resolvelib/resolvers.py +++ b/src/pip/_vendor/resolvelib/resolvers.py @@ -212,7 +212,7 @@ def _attempt_to_pin_criterion(self, name): try: criteria = self._get_updated_criteria(candidate) except RequirementsConflicted as e: - self._r.discarding_conflicted_criterion(e.criterion, candidate) + self._r.backtracking(e.criterion, candidate) causes.append(e.criterion) continue @@ -282,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():