Skip to content

Commit a276c78

Browse files
committed
Fix direct preference in PipProvider.get_preference
1 parent 459249e commit a276c78

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .base import Candidate, Constraint, Requirement
1717
from .candidates import REQUIRES_PYTHON_IDENTIFIER
1818
from .factory import Factory
19+
from .requirements import ExplicitRequirement
1920

2021
if TYPE_CHECKING:
2122
from pip._vendor.resolvelib.providers import Preference
@@ -138,17 +139,19 @@ def get_preference(
138139

139140
if has_information:
140141
lookups = (r.get_candidate_lookup() for r, _ in information[identifier])
141-
candidate, ireqs = zip(*lookups)
142+
_icandidates, ireqs = zip(*lookups)
142143
else:
143-
candidate, ireqs = None, ()
144+
_icandidates, ireqs = (), ()
144145

145146
operators: list[tuple[str, str]] = [
146147
(specifier.operator, specifier.version)
147148
for specifier_set in (ireq.specifier for ireq in ireqs if ireq)
148149
for specifier in specifier_set
149150
]
150151

151-
direct = candidate is not None
152+
direct = any(
153+
isinstance(r, ExplicitRequirement) for r, _ in information[identifier]
154+
)
152155
pinned = any(((op[:2] == "==") and ("*" not in ver)) for op, ver in operators)
153156
unfree = bool(operators)
154157
requested_order = self._user_requested.get(identifier, math.inf)

0 commit comments

Comments
 (0)