Skip to content

Commit 50cd318

Browse files
committed
review comment: renamed and moved up ExtrasCandidate._ireq
1 parent 4e73e3e commit 50cd318

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,11 @@ def __init__(
427427
self,
428428
base: BaseCandidate,
429429
extras: FrozenSet[str],
430-
ireq: Optional[InstallRequirement] = None,
430+
*,
431+
comes_from: Optional[InstallRequirement] = None,
431432
) -> None:
432433
"""
433-
:param ireq: the InstallRequirement that led to this candidate, if it
434+
:param ireq: the InstallRequirement that led to this candidate if it
434435
differs from the base's InstallRequirement. This will often be the
435436
case in the sense that this candidate's requirement has the extras
436437
while the base's does not. Unlike the InstallRequirement backed
@@ -439,7 +440,7 @@ def __init__(
439440
"""
440441
self.base = base
441442
self.extras = extras
442-
self._ireq = ireq
443+
self._comes_from = comes_from if comes_from is not None else self.base._ireq
443444

444445
def __str__(self) -> str:
445446
name, rest = str(self.base).split(" ", 1)
@@ -514,7 +515,7 @@ def iter_dependencies(self, with_requires: bool) -> Iterable[Optional[Requiremen
514515
for r in self.base.dist.iter_dependencies(valid_extras):
515516
yield from factory.make_requirements_from_spec(
516517
str(r),
517-
self._ireq if self._ireq is not None else self.base._ireq,
518+
self._comes_from,
518519
valid_extras,
519520
)
520521

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ def _make_extras_candidate(
142142
self,
143143
base: BaseCandidate,
144144
extras: FrozenSet[str],
145-
ireq: Optional[InstallRequirement] = None,
145+
*,
146+
comes_from: Optional[InstallRequirement] = None,
146147
) -> ExtrasCandidate:
147148
cache_key = (id(base), extras)
148149
try:
149150
candidate = self._extras_candidate_cache[cache_key]
150151
except KeyError:
151-
candidate = ExtrasCandidate(base, extras, ireq=ireq)
152+
candidate = ExtrasCandidate(base, extras, comes_from=comes_from)
152153
self._extras_candidate_cache[cache_key] = candidate
153154
return candidate
154155

@@ -165,7 +166,7 @@ def _make_candidate_from_dist(
165166
self._installed_candidate_cache[dist.canonical_name] = base
166167
if not extras:
167168
return base
168-
return self._make_extras_candidate(base, extras, ireq=template)
169+
return self._make_extras_candidate(base, extras, comes_from=template)
169170

170171
def _make_candidate_from_link(
171172
self,
@@ -227,7 +228,7 @@ def _make_candidate_from_link(
227228

228229
if not extras:
229230
return base
230-
return self._make_extras_candidate(base, extras, ireq=template)
231+
return self._make_extras_candidate(base, extras, comes_from=template)
231232

232233
def _iter_found_candidates(
233234
self,

0 commit comments

Comments
 (0)