Skip to content

Commit

Permalink
Fix type hints for resolvelib 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
notatallshaw committed Nov 10, 2024
1 parent 9308566 commit 3a157bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 6 additions & 4 deletions src/pip/_internal/resolution/resolvelib/reporter.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 3a157bb

Please sign in to comment.