|
16 | 16 | cast,
|
17 | 17 | )
|
18 | 18 |
|
19 |
| -from pip._vendor.packaging.requirements import ( |
20 |
| - InvalidRequirement, |
21 |
| - Requirement as PackagingRequirement, |
22 |
| -) |
| 19 | +from pip._vendor.packaging.requirements import InvalidRequirement |
| 20 | +from pip._vendor.packaging.requirements import Requirement as PackagingRequirement |
23 | 21 | from pip._vendor.packaging.specifiers import SpecifierSet
|
24 | 22 | from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
25 | 23 | from pip._vendor.pkg_resources import Distribution
|
|
57 | 55 | ExtrasCandidate,
|
58 | 56 | LinkCandidate,
|
59 | 57 | RequiresPythonCandidate,
|
| 58 | + as_base_candidate, |
60 | 59 | )
|
61 | 60 | from .found_candidates import FoundCandidates, IndexCandidateInfo
|
62 | 61 | from .requirements import (
|
@@ -306,15 +305,19 @@ def find_candidates(
|
306 | 305 | identifier_req = PackagingRequirement(identifier)
|
307 | 306 | except InvalidRequirement:
|
308 | 307 | base_identifier = None
|
309 |
| - extras = frozenset() |
| 308 | + extras: FrozenSet[str] = frozenset() |
310 | 309 | else:
|
311 | 310 | base_identifier = identifier_req.name
|
312 | 311 | extras = frozenset(identifier_req.extras)
|
313 | 312 | if base_identifier and base_identifier in requirements:
|
314 | 313 | for req in requirements[base_identifier]:
|
315 |
| - base_cand, _ = req.get_candidate_lookup() |
316 |
| - if base_cand is None: |
| 314 | + lookup_cand, _ = req.get_candidate_lookup() |
| 315 | + if lookup_cand is None: # Not explicit. |
317 | 316 | continue
|
| 317 | + # We've stripped extras from the identifier, and should always |
| 318 | + # get a BaseCandidate here, unless there's a bug elsewhere. |
| 319 | + base_cand = as_base_candidate(lookup_cand) |
| 320 | + assert base_cand is not None |
318 | 321 | candidate = self._make_extras_candidate(base_cand, extras)
|
319 | 322 | explicit_candidates.add(candidate)
|
320 | 323 |
|
|
0 commit comments