Changed type of variadic args to Any and removed unneeded type ignore

This commit is contained in:
Devesh Kumar Singh 2020-04-14 12:06:21 +05:30
parent 0e8093ec5c
commit 3b35b416e9
3 changed files with 17 additions and 16 deletions

View File

@ -12,7 +12,7 @@ from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import Any, List, Dict
from typing import Any, List
logger = logging.getLogger(__name__)
@ -29,9 +29,8 @@ class HashCommand(Command):
ignore_require_venv = True
def __init__(self, *args, **kw):
# type: (List[Any], Dict[Any, Any]) -> None
# https://github.com/python/mypy/issues/4335
super(HashCommand, self).__init__(*args, **kw) # type: ignore
# type: (*Any, **Any) -> None
super(HashCommand, self).__init__(*args, **kw)
self.cmd_opts.add_option(
'-a', '--algorithm',
dest='algorithm',
@ -43,7 +42,7 @@ class HashCommand(Command):
self.parser.insert_option_group(0, self.cmd_opts)
def run(self, options, args):
# type: (Values, List[Any]) -> int
# type: (Values, List[str]) -> int
if not args:
self.parser.print_usage(sys.stderr)
return ERROR

View File

@ -31,9 +31,8 @@ class ShowCommand(Command):
ignore_require_venv = True
def __init__(self, *args, **kw):
# type: (List[Any], Dict[Any, Any]) -> None
# https://github.com/python/mypy/issues/4335
super(ShowCommand, self).__init__(*args, **kw) # type: ignore
# type: (*Any, **Any) -> None
super(ShowCommand, self).__init__(*args, **kw)
self.cmd_opts.add_option(
'-f', '--files',
dest='files',
@ -44,7 +43,7 @@ class ShowCommand(Command):
self.parser.insert_option_group(0, self.cmd_opts)
def run(self, options, args):
# type: (Values, List[Any]) -> int
# type: (Values, List[str]) -> int
if not args:
logger.warning('ERROR: Please provide a package name or names.')
return ERROR
@ -58,7 +57,7 @@ class ShowCommand(Command):
def search_packages_info(query):
# type: (List[Any]) -> Iterator[Dict[str, Any]]
# type: (List[str]) -> Iterator[Dict[str, str]]
"""
Gather details from installed distributions. Print distribution name,
version, location, and installed files. Installed files requires a
@ -95,6 +94,10 @@ def search_packages_info(query):
'required_by': get_requiring_packages(dist.project_name)
}
file_list = None
# Set metadata to empty string to avoid metadata being typed as
# Optional[Any] in function calls using metadata below
# and since dist.get_metadata returns us a str, the default
# value of empty string should be valid
metadata = ''
if isinstance(dist, pkg_resources.DistInfoDistribution):
# RECORDs should be part of .dist-info metadatas
@ -148,7 +151,7 @@ def search_packages_info(query):
def print_results(distributions, list_files=False, verbose=False):
# type: (Iterator[Dict[str, Any]], bool, bool) -> bool
# type: (Iterator[Dict[str, str]], bool, bool) -> bool
"""
Print the information from installed distributions found.
"""

View File

@ -19,7 +19,7 @@ from pip._internal.wheel_builder import build, should_build_for_wheel_command
if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import Any, List, Dict
from typing import Any, List
logger = logging.getLogger(__name__)
@ -48,9 +48,8 @@ class WheelCommand(RequirementCommand):
%prog [options] <archive url/path> ..."""
def __init__(self, *args, **kw):
# type: (List[Any], Dict[Any, Any]) -> None
# https://github.com/python/mypy/issues/4335
super(WheelCommand, self).__init__(*args, **kw) # type: ignore
# type: (*Any, **Any) -> None
super(WheelCommand, self).__init__(*args, **kw)
cmd_opts = self.cmd_opts
@ -112,7 +111,7 @@ class WheelCommand(RequirementCommand):
@with_cleanup
def run(self, options, args):
# type: (Values, List[Any]) -> int
# type: (Values, List[str]) -> int
cmdoptions.check_install_build_global(options)
session = self.get_default_session(options)