diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index dc6e2e12e1f..1fe11f53463 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -748,7 +748,7 @@ def get_installation_error( # The simplest case is when we have *one* cause that can't be # satisfied. We just report that case. if len(e.causes) == 1: - req, parent = e.causes[0] + req, parent = next(iter(e.causes)) if req.name not in constraints: return self._report_single_requirement_conflict(req, parent) diff --git a/src/pip/_internal/resolution/resolvelib/reporter.py b/src/pip/_internal/resolution/resolvelib/reporter.py index 0594569d850..f8ad815fe9f 100644 --- a/src/pip/_internal/resolution/resolvelib/reporter.py +++ b/src/pip/_internal/resolution/resolvelib/reporter.py @@ -1,6 +1,6 @@ from collections import defaultdict from logging import getLogger -from typing import Any, DefaultDict +from typing import Any, DefaultDict, Optional from pip._vendor.resolvelib.reporters import BaseReporter @@ -9,7 +9,7 @@ logger = getLogger(__name__) -class PipReporter(BaseReporter): +class PipReporter(BaseReporter[Requirement, Candidate, str]): def __init__(self) -> None: self.reject_count_by_package: DefaultDict[str, int] = defaultdict(int) @@ -55,7 +55,7 @@ def rejecting_candidate(self, criterion: Any, candidate: Candidate) -> None: logger.debug(msg) -class PipDebuggingReporter(BaseReporter): +class PipDebuggingReporter(BaseReporter[Requirement, Candidate, str]): """A reporter that does an info log for every event it sees.""" def starting(self) -> None: @@ -71,7 +71,9 @@ def ending_round(self, index: int, state: Any) -> None: def ending(self, state: Any) -> None: logger.info("Reporter.ending(%r)", state) - def adding_requirement(self, requirement: Requirement, parent: Candidate) -> None: + def adding_requirement( + self, requirement: Requirement, parent: Optional[Candidate] + ) -> None: logger.info("Reporter.adding_requirement(%r, %r)", requirement, parent) def rejecting_candidate(self, criterion: Any, candidate: Candidate) -> None: diff --git a/src/pip/_internal/resolution/resolvelib/resolver.py b/src/pip/_internal/resolution/resolvelib/resolver.py index c12beef0b2a..e6d5f303740 100644 --- a/src/pip/_internal/resolution/resolvelib/resolver.py +++ b/src/pip/_internal/resolution/resolvelib/resolver.py @@ -82,7 +82,7 @@ def resolve( user_requested=collected.user_requested, ) if "PIP_RESOLVER_DEBUG" in os.environ: - reporter: BaseReporter = PipDebuggingReporter() + reporter: BaseReporter[Requirement, Candidate, str] = PipDebuggingReporter() else: reporter = PipReporter() resolver: RLResolver[Requirement, Candidate, str] = RLResolver(