提交 ffb56db5 编写于 作者: P Paul Moore

Allow candidates to not have an associated install requirement

上级 d79aacc6
......@@ -3,7 +3,7 @@ from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
from typing import Sequence, Set
from typing import Optional, Sequence, Set
from pip._internal.req.req_install import InstallRequirement
from pip._vendor.packaging.version import _BaseVersion
......@@ -48,5 +48,5 @@ class Candidate(object):
raise NotImplementedError("Override in subclass")
def get_install_requirement(self):
# type: () -> InstallRequirement
# type: () -> Optional[InstallRequirement]
raise NotImplementedError("Override in subclass")
......@@ -130,7 +130,7 @@ class LinkCandidate(Candidate):
return [self._make_install_req(str(r)) for r in self.dist.requires()]
def get_install_requirement(self):
# type: () -> InstallRequirement
# type: () -> Optional[InstallRequirement]
return self._ireq
......@@ -168,5 +168,8 @@ class ExtrasCandidate(LinkCandidate):
return deps
def get_install_requirement(self):
# type: () -> InstallRequirement
return self.base.get_install_requirement()
# type: () -> Optional[InstallRequirement]
# We don't return anything here, because we always
# depend on the base candidate, and we'll get the
# install requirement from that.
return None
......@@ -37,7 +37,7 @@ class PipProvider(AbstractProvider):
)
def get_install_requirement(self, c):
# type: (Candidate) -> InstallRequirement
# type: (Candidate) -> Optional[InstallRequirement]
return c.get_install_requirement()
def identify(self, dependency):
......
......@@ -56,7 +56,8 @@ class Resolver(BaseResolver):
req_set = RequirementSet(check_supported_wheels=check_supported_wheels)
for candidate in self._result.mapping.values():
ireq = provider.get_install_requirement(candidate)
req_set.add_named_requirement(ireq)
if ireq is not None:
req_set.add_named_requirement(ireq)
return req_set
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册