mirror of https://github.com/pypa/pip
Make a proper get_install_requirement method for candidates
This commit is contained in:
parent
653bac26c9
commit
76de49bc24
|
@ -46,3 +46,7 @@ class Candidate(object):
|
|||
def get_dependencies(self):
|
||||
# type: () -> Sequence[InstallRequirement]
|
||||
raise NotImplementedError("Override in subclass")
|
||||
|
||||
def get_install_requirement(self):
|
||||
# type: () -> InstallRequirement
|
||||
raise NotImplementedError("Override in subclass")
|
||||
|
|
|
@ -124,3 +124,7 @@ class LinkCandidate(Candidate):
|
|||
self._make_install_req(str(r), self._ireq)
|
||||
for r in self.dist.requires()
|
||||
]
|
||||
|
||||
def get_install_requirement(self):
|
||||
# type: () -> InstallRequirement
|
||||
return self._ireq
|
||||
|
|
|
@ -38,15 +38,7 @@ class PipProvider(AbstractProvider):
|
|||
|
||||
def get_install_requirement(self, c):
|
||||
# type: (Candidate) -> InstallRequirement
|
||||
|
||||
# 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)
|
||||
return c.get_install_requirement()
|
||||
|
||||
def identify(self, dependency):
|
||||
# type: (Union[Requirement, Candidate]) -> str
|
||||
|
|
Loading…
Reference in New Issue