提交 76de49bc 编写于 作者: P Paul Moore

Make a proper get_install_requirement method for candidates

上级 653bac26
...@@ -46,3 +46,7 @@ class Candidate(object): ...@@ -46,3 +46,7 @@ class Candidate(object):
def get_dependencies(self): def get_dependencies(self):
# type: () -> Sequence[InstallRequirement] # type: () -> Sequence[InstallRequirement]
raise NotImplementedError("Override in subclass") raise NotImplementedError("Override in subclass")
def get_install_requirement(self):
# type: () -> InstallRequirement
raise NotImplementedError("Override in subclass")
...@@ -124,3 +124,7 @@ class LinkCandidate(Candidate): ...@@ -124,3 +124,7 @@ class LinkCandidate(Candidate):
self._make_install_req(str(r), self._ireq) self._make_install_req(str(r), self._ireq)
for r in self.dist.requires() for r in self.dist.requires()
] ]
def get_install_requirement(self):
# type: () -> InstallRequirement
return self._ireq
...@@ -38,15 +38,7 @@ class PipProvider(AbstractProvider): ...@@ -38,15 +38,7 @@ class PipProvider(AbstractProvider):
def get_install_requirement(self, c): def get_install_requirement(self, c):
# type: (Candidate) -> InstallRequirement # type: (Candidate) -> InstallRequirement
return c.get_install_requirement()
# The base Candidate class does not have an _ireq attribute, so we
# fetch it dynamically here, to satisfy mypy. In practice, though, we
# only ever deal with LinkedCandidate objects at the moment, which do
# have an _ireq attribute. When we have a candidate type for installed
# requirements we should probably review this.
#
# TODO: Longer term, make a proper interface for this on the candidate.
return getattr(c, "_ireq", None)
def identify(self, dependency): def identify(self, dependency):
# type: (Union[Requirement, Candidate]) -> str # type: (Union[Requirement, Candidate]) -> str
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册