Type annotations for pip._internal.commands.download
-# The following comment should be removed at some point in the future.
-# mypy: disallow-untyped-defs=False
-
from __future__ import absolute_import
import logging
@@ -12,6 +9,12 @@ from pip._internal.cli.req_command import RequirementCommand, with_cleanup
from pip._internal.req.req_tracker import get_requirement_tracker
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
from pip._internal.utils.temp_dir import TempDirectory
+from pip._internal.utils.typing import MYPY_CHECK_RUNNING
+
+if MYPY_CHECK_RUNNING:
+ from optparse import Values
+ from typing import Any, List
+ from pip._internal.req.req_set import RequirementSet
logger = logging.getLogger(__name__)
@@ -37,6 +40,7 @@ class DownloadCommand(RequirementCommand):
%prog [options] <archive url/path> ..."""
def __init__(self, *args, **kw):
+ # type: (*Any, **Any) -> None
super(DownloadCommand, self).__init__(*args, **kw)
cmd_opts = self.cmd_opts
@@ -77,6 +81,8 @@ class DownloadCommand(RequirementCommand):
@with_cleanup
def run(self, options, args):
+ # type: (Values, List[str]) -> RequirementSet
+
options.ignore_installed = True
# editable doesn't really make sense for `pip download`, but the bowels
# of the RequirementSet code require that property.
@@ -134,7 +140,7 @@ class DownloadCommand(RequirementCommand):
downloaded = ' '.join([
req.name for req in requirement_set.requirements.values()
- if req.successfully_downloaded
+ if req.successfully_downloaded and req.name
])
if downloaded:
write_output('Successfully downloaded %s', downloaded)
