12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- """Runs Pylint and Pytype ."""
15
+ """Runs Pylint."""
16
16
17
17
import argparse
18
18
import json
19
19
import os
20
20
import os .path
21
21
import pathlib
22
- import platform
23
22
import shutil
24
23
import sys
25
24
import subprocess
@@ -37,16 +36,15 @@ def main() -> None:
37
36
subparsers = parser .add_subparsers (required = True , dest = 'program' )
38
37
pylint = subparsers .add_parser ('pylint' , allow_abbrev = False )
39
38
pylint .add_argument ('--pylintrc' , type = pathlib .Path , required = True )
40
- subparsers .add_parser ('pytype' , allow_abbrev = False )
41
39
args = parser .parse_args ()
42
40
workspace_name = args .workspace_name
43
41
dirs = [d for d in sys .path if os .path .basename (d ) == workspace_name ]
44
42
if len (dirs ) != 1 :
45
43
raise ValueError (f'no unique workspace directory: { dirs } ' )
46
44
module_space = pathlib .Path (dirs [0 ]).parent
47
45
module_space_stat = module_space .stat ()
48
- # Set a fake PYTHONPATH so that Pylint and Pytype can find imports for the
49
- # main and external repositories.
46
+ # Set a fake PYTHONPATH so that Pylint can find imports for the main and
47
+ # external repositories.
50
48
params = json .loads (args .params .read_text (encoding = 'utf-8' ))
51
49
srcs = []
52
50
tempdir = pathlib .Path (tempfile .mkdtemp (prefix = 'pylint-' ))
@@ -67,11 +65,6 @@ def main() -> None:
67
65
(path / '__init__.py' ).touch ()
68
66
srcset = frozenset (srcs )
69
67
repository_path = [str (tempdir / d ) for d in args .path ]
70
- # Pytype wants a Python binary available under the name “python”. See the
71
- # function pytype.tools.environment.check_python_exe_or_die.
72
- bindir = tempdir / 'bin'
73
- bindir .mkdir ()
74
- (bindir / 'python' ).symlink_to (sys .executable )
75
68
orig_path = []
76
69
for entry in sys .path :
77
70
try :
@@ -87,7 +80,6 @@ def main() -> None:
87
80
pass # ignore nonexisting entries
88
81
cwd = tempdir / workspace_name
89
82
env = dict (os .environ ,
90
- PATH = os .pathsep .join ([str (bindir )] + os .get_exec_path ()),
91
83
PYTHONPATH = os .pathsep .join (orig_path + repository_path ))
92
84
if args .program == 'pylint' :
93
85
result = subprocess .run (
@@ -102,18 +94,6 @@ def main() -> None:
102
94
if result .returncode :
103
95
print (result .stdout )
104
96
sys .exit (result .returncode )
105
- if platform .system () != 'Windows' and args .program == 'pytype' :
106
- result = subprocess .run (
107
- [sys .executable , '-m' , 'pytype' ,
108
- '--pythonpath=' + os .pathsep .join (repository_path ),
109
- '--no-cache' , '--' ] + [str (file .relative_to (cwd ))
110
- for file in sorted (srcset )],
111
- check = False , cwd = cwd , env = env ,
112
- stdout = subprocess .PIPE , stderr = subprocess .STDOUT ,
113
- encoding = 'utf-8' , errors = 'backslashreplace' )
114
- if result .returncode :
115
- print (result .stdout )
116
- sys .exit (result .returncode )
117
97
# Only clean up the workspace if we exited successfully, to help with
118
98
# debugging.
119
99
shutil .rmtree (tempdir )
0 commit comments