diff --git a/news/C7A26013-0E79-4DBB-B0E3-2DA5C5587CDC.trivial b/news/C7A26013-0E79-4DBB-B0E3-2DA5C5587CDC.trivial new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/pip/_internal/commands/completion.py b/src/pip/_internal/commands/completion.py index 910fcbfe358..70d33243fcd 100644 --- a/src/pip/_internal/commands/completion.py +++ b/src/pip/_internal/commands/completion.py @@ -1,13 +1,16 @@ -# The following comment should be removed at some point in the future. -# mypy: disallow-untyped-defs=False - from __future__ import absolute_import import sys import textwrap from pip._internal.cli.base_command import Command +from pip._internal.cli.status_codes import SUCCESS from pip._internal.utils.misc import get_prog +from pip._internal.utils.typing import MYPY_CHECK_RUNNING + +if MYPY_CHECK_RUNNING: + from typing import Any, List + from optparse import Values BASE_COMPLETION = """ # pip {shell} completion start{script}# pip {shell} completion end @@ -54,6 +57,7 @@ class CompletionCommand(Command): ignore_require_venv = True def __init__(self, *args, **kw): + # type: (*Any, **Any) -> None super(CompletionCommand, self).__init__(*args, **kw) cmd_opts = self.cmd_opts @@ -80,6 +84,7 @@ def __init__(self, *args, **kw): self.parser.insert_option_group(0, cmd_opts) def run(self, options, args): + # type: (Values, List[str]) -> int """Prints the completion code of the given shell""" shells = COMPLETION_SCRIPTS.keys() shell_options = ['--' + shell for shell in sorted(shells)] @@ -89,7 +94,9 @@ def run(self, options, args): prog=get_prog()) ) print(BASE_COMPLETION.format(script=script, shell=options.shell)) + return SUCCESS else: sys.stderr.write( 'ERROR: You must pass {}\n' .format(' or '.join(shell_options)) ) + return SUCCESS diff --git a/src/pip/_internal/commands/debug.py b/src/pip/_internal/commands/debug.py index b7c92fa6598..8e243011f97 100644 --- a/src/pip/_internal/commands/debug.py +++ b/src/pip/_internal/commands/debug.py @@ -1,6 +1,3 @@ -# The following comment should be removed at some point in the future. -# mypy: disallow-untyped-defs=False - from __future__ import absolute_import import locale @@ -67,7 +64,6 @@ def create_vendor_txt_map(): def get_module_from_module_name(module_name): # type: (str) -> ModuleType - # Module name can be uppercase in vendor.txt for some reason... module_name = module_name.lower() # PATCH: setuptools is actually only pkg_resources. @@ -84,8 +80,7 @@ def get_module_from_module_name(module_name): def get_vendor_version_from_module(module_name): - # type: (str) -> str - + # type: (str) -> Optional[str] module = get_module_from_module_name(module_name) version = getattr(module, '__version__', None) @@ -169,6 +164,7 @@ def show_tags(options): def ca_bundle_info(config): + # type: (Dict[str, str]) -> str levels = set() for key, value in config.items(): levels.add(key.split('.')[0]) @@ -198,6 +194,7 @@ class DebugCommand(Command): ignore_require_venv = True def __init__(self, *args, **kw): + # type: (*Any, **Any) -> None super(DebugCommand, self).__init__(*args, **kw) cmd_opts = self.cmd_opts @@ -206,7 +203,7 @@ def __init__(self, *args, **kw): self.parser.config.load() def run(self, options, args): - # type: (Values, List[Any]) -> int + # type: (Values, List[str]) -> int logger.warning( "This command is only meant for debugging. " "Do not use this with automation for parsing and getting these "