1
- # The following comment should be removed at some point in the future.
2
- # mypy: disallow-untyped-defs=False
3
-
4
1
from __future__ import absolute_import
5
2
6
3
import logging
13
10
from pip ._internal .cli .base_command import Command
14
11
from pip ._internal .cli .status_codes import ERROR , SUCCESS
15
12
from pip ._internal .utils .misc import write_output
13
+ from pip ._internal .utils .typing import MYPY_CHECK_RUNNING
14
+
15
+ if MYPY_CHECK_RUNNING :
16
+ from optparse import Values
17
+ from typing import Any , List , Dict , Iterator
16
18
17
19
logger = logging .getLogger (__name__ )
18
20
@@ -29,7 +31,9 @@ class ShowCommand(Command):
29
31
ignore_require_venv = True
30
32
31
33
def __init__ (self , * args , ** kw ):
32
- super (ShowCommand , self ).__init__ (* args , ** kw )
34
+ # type: (List[Any], Dict[Any, Any]) -> None
35
+ # https://github.com/python/mypy/issues/4335
36
+ super (ShowCommand , self ).__init__ (* args , ** kw ) # type: ignore
33
37
self .cmd_opts .add_option (
34
38
'-f' , '--files' ,
35
39
dest = 'files' ,
@@ -40,6 +44,7 @@ def __init__(self, *args, **kw):
40
44
self .parser .insert_option_group (0 , self .cmd_opts )
41
45
42
46
def run (self , options , args ):
47
+ # type: (Values, List[Any]) -> int
43
48
if not args :
44
49
logger .warning ('ERROR: Please provide a package name or names.' )
45
50
return ERROR
@@ -53,6 +58,7 @@ def run(self, options, args):
53
58
54
59
55
60
def search_packages_info (query ):
61
+ # type: (List[Any]) -> Iterator[Dict[str, Any]]
56
62
"""
57
63
Gather details from installed distributions. Print distribution name,
58
64
version, location, and installed files. Installed files requires a
@@ -71,6 +77,7 @@ def search_packages_info(query):
71
77
logger .warning ('Package(s) not found: %s' , ', ' .join (missing ))
72
78
73
79
def get_requiring_packages (package_name ):
80
+ # type: (str) -> List[str]
74
81
canonical_name = canonicalize_name (package_name )
75
82
return [
76
83
pkg .project_name for pkg in pkg_resources .working_set
@@ -88,7 +95,7 @@ def get_requiring_packages(package_name):
88
95
'required_by' : get_requiring_packages (dist .project_name )
89
96
}
90
97
file_list = None
91
- metadata = None
98
+ metadata = ''
92
99
if isinstance (dist , pkg_resources .DistInfoDistribution ):
93
100
# RECORDs should be part of .dist-info metadatas
94
101
if dist .has_metadata ('RECORD' ):
@@ -141,6 +148,7 @@ def get_requiring_packages(package_name):
141
148
142
149
143
150
def print_results (distributions , list_files = False , verbose = False ):
151
+ # type: (Iterator[Dict[str, Any]], bool, bool) -> bool
144
152
"""
145
153
Print the information from installed distributions found.
146
154
"""
0 commit comments