mirror of https://github.com/pypa/pip
Type hint hacks
This commit is contained in:
parent
2430aba879
commit
05f7dbd0c8
|
@ -28,6 +28,12 @@ if MYPY_CHECK_RUNNING:
|
|||
from .base import Requirement
|
||||
from .factory import Factory
|
||||
|
||||
BaseCandidate = Union[
|
||||
"AlreadyInstalledCandidate",
|
||||
"EditableCandidate",
|
||||
"LinkCandidate",
|
||||
]
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -54,7 +60,10 @@ def make_install_req_from_editable(link, parent):
|
|||
assert parent.editable, "parent not editable"
|
||||
return install_req_from_editable(
|
||||
link.url,
|
||||
comes_from=parent.comes_from,
|
||||
# HACK: install_req_from_editable accepts Optional[str] here, but
|
||||
# parent.comes_from is Union[str, InstallRequirement, None]. How do
|
||||
# we fix the type hint conflicts?
|
||||
comes_from=parent.comes_from, # type: ignore
|
||||
use_pep517=parent.use_pep517,
|
||||
isolated=parent.isolated,
|
||||
constraint=parent.constraint,
|
||||
|
@ -302,7 +311,7 @@ class ExtrasCandidate(Candidate):
|
|||
"""
|
||||
def __init__(
|
||||
self,
|
||||
base, # type: Union[AlreadyInstalledCandidate, LinkCandidate]
|
||||
base, # type: BaseCandidate
|
||||
extras, # type: Set[str]
|
||||
):
|
||||
# type: (...) -> None
|
||||
|
|
|
@ -34,6 +34,7 @@ if MYPY_CHECK_RUNNING:
|
|||
from pip._internal.resolution.base import InstallRequirementProvider
|
||||
|
||||
from .base import Candidate, Requirement
|
||||
from .candidates import BaseCandidate
|
||||
|
||||
C = TypeVar("C")
|
||||
Cache = Dict[Link, C]
|
||||
|
@ -85,7 +86,7 @@ class Factory(object):
|
|||
self._editable_candidate_cache[link] = EditableCandidate(
|
||||
link, parent, factory=self, name=name, version=version,
|
||||
)
|
||||
base = self._editable_candidate_cache[link]
|
||||
base = self._editable_candidate_cache[link] # type: BaseCandidate
|
||||
else:
|
||||
if link not in self._link_candidate_cache:
|
||||
self._link_candidate_cache[link] = LinkCandidate(
|
||||
|
|
Loading…
Reference in New Issue