Start type checking commands/install.py and commands/wheel.py.

This commit is contained in:
Chris Jerdonek 2019-08-11 04:13:44 -07:00
parent 6f0e873182
commit 698b27b875
2 changed files with 31 additions and 5 deletions

View File

@ -1,3 +1,10 @@
# The following comment should be removed at some point in the future.
# It's included for now because without it InstallCommand.run() has a
# couple errors where we have to know req.name is str rather than
# Optional[str] for the InstallRequirement req.
# mypy: strict-optional=False
from __future__ import absolute_import
import errno
@ -13,7 +20,7 @@ from pip._internal.cache import WheelCache
from pip._internal.cli import cmdoptions
from pip._internal.cli.cmdoptions import make_target_python
from pip._internal.cli.req_command import RequirementCommand
from pip._internal.cli.status_codes import ERROR
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.exceptions import (
CommandError,
InstallationError,
@ -30,9 +37,17 @@ from pip._internal.utils.misc import (
protect_pip_from_modification_on_windows,
)
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import virtualenv_no_global
from pip._internal.wheel import WheelBuilder
if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import Any, List
from pip._internal.req.req_install import InstallRequirement
logger = logging.getLogger(__name__)
@ -242,6 +257,7 @@ class InstallCommand(RequirementCommand):
self.parser.insert_option_group(0, cmd_opts)
def run(self, options, args):
# type: (Values, List[Any]) -> int
cmdoptions.check_install_build_global(options)
upgrade_strategy = "to-satisfy-only"
if options.upgrade:
@ -425,9 +441,11 @@ class InstallCommand(RequirementCommand):
except Exception:
pass
items.append(item)
installed = ' '.join(items)
if installed:
logger.info('Successfully installed %s', installed)
installed_desc = ' '.join(items)
if installed_desc:
logger.info(
'Successfully installed %s', installed_desc,
)
except EnvironmentError as error:
show_traceback = (self.verbosity >= 1)
@ -450,7 +468,8 @@ class InstallCommand(RequirementCommand):
self._handle_target_dir(
options.target_dir, target_temp_dir, options.upgrade
)
return requirement_set
return SUCCESS
def _handle_target_dir(self, target_dir, target_temp_dir, upgrade):
ensure_dir(target_dir)

View File

@ -11,8 +11,14 @@ from pip._internal.exceptions import CommandError, PreviousBuildDirError
from pip._internal.req import RequirementSet
from pip._internal.req.req_tracker import RequirementTracker
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.wheel import WheelBuilder
if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import Any, List
logger = logging.getLogger(__name__)
@ -101,6 +107,7 @@ class WheelCommand(RequirementCommand):
self.parser.insert_option_group(0, cmd_opts)
def run(self, options, args):
# type: (Values, List[Any]) -> None
cmdoptions.check_install_build_global(options)
if options.build_dir: