Skip to content

Commit d3a78eb

Browse files
authored
Merge pull request #10261 from jdufresne/found-candidates-six
Remove six import in resolution/resolvelib/found_candidates.py
2 parents 5f7189b + a3628b7 commit d3a78eb

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

news/69311721-677c-46c7-9f29-31a40dddee99.trivial.rst

Whitespace-only changes.

src/pip/_internal/resolution/resolvelib/found_candidates.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,30 @@
99
"""
1010

1111
import functools
12-
from typing import Callable, Iterator, Optional, Set, Tuple
12+
from collections.abc import Sequence
13+
from typing import TYPE_CHECKING, Any, Callable, Iterator, Optional, Set, Tuple
1314

1415
from pip._vendor.packaging.version import _BaseVersion
15-
from pip._vendor.six.moves import collections_abc # type: ignore
1616

1717
from .base import Candidate
1818

1919
IndexCandidateInfo = Tuple[_BaseVersion, Callable[[], Optional[Candidate]]]
2020

21+
if TYPE_CHECKING:
22+
SequenceCandidate = Sequence[Candidate]
23+
else:
24+
# For compatibility: Python before 3.9 does not support using [] on the
25+
# Sequence class.
26+
#
27+
# >>> from collections.abc import Sequence
28+
# >>> Sequence[str]
29+
# Traceback (most recent call last):
30+
# File "<stdin>", line 1, in <module>
31+
# TypeError: 'ABCMeta' object is not subscriptable
32+
#
33+
# TODO: Remove this block after dropping Python 3.8 support.
34+
SequenceCandidate = Sequence
35+
2136

2237
def _iter_built(infos: Iterator[IndexCandidateInfo]) -> Iterator[Candidate]:
2338
"""Iterator for ``FoundCandidates``.
@@ -90,7 +105,7 @@ def _iter_built_with_inserted(
90105
yield installed
91106

92107

93-
class FoundCandidates(collections_abc.Sequence):
108+
class FoundCandidates(SequenceCandidate):
94109
"""A lazy sequence to provide candidates to the resolver.
95110
96111
The intended usage is to return this from `find_matches()` so the resolver
@@ -111,7 +126,7 @@ def __init__(
111126
self._prefers_installed = prefers_installed
112127
self._incompatible_ids = incompatible_ids
113128

114-
def __getitem__(self, index: int) -> Candidate:
129+
def __getitem__(self, index: Any) -> Any:
115130
# Implemented to satisfy the ABC check. This is not needed by the
116131
# resolver, and should not be used by the provider either (for
117132
# performance reasons).

0 commit comments

Comments
 (0)