@@ -8,6 +8,8 @@ import sys
8
8
import argparse
9
9
import subprocess
10
10
11
+ from collections import OrderedDict
12
+ from pathlib import PurePath
11
13
from server_lib import lister
12
14
from typing import cast , Dict , List
13
15
@@ -42,11 +44,8 @@ zulip_botserver/zulip_botserver/server.py
42
44
zulip_botserver/setup.py
43
45
""" .split ()
44
46
45
- default_targets = ['zulip/zulip' ,
46
- 'zulip/setup.py' ]
47
-
48
47
parser = argparse .ArgumentParser (description = "Run mypy on files tracked by git." )
49
- parser .add_argument ('targets' , nargs = '*' , default = default_targets ,
48
+ parser .add_argument ('targets' , nargs = '*' , default = [] ,
50
49
help = """files and directories to include in the result.
51
50
If this is not specified, the current directory is used""" )
52
51
parser .add_argument ('-m' , '--modified' , action = 'store_true' , default = False , help = 'list only modified files' )
@@ -80,6 +79,12 @@ pyi_files = set(files_dict['pyi'])
80
79
python_files = [fpath for fpath in files_dict ['py' ]
81
80
if not fpath .endswith ('.py' ) or fpath + 'i' not in pyi_files ]
82
81
82
+ repo_python_files = OrderedDict ([('zulip' , []), ('zulip_bots' , []), ('zulip_botserver' , [])])
83
+ for file_path in python_files :
84
+ repo = PurePath (file_path ).parts [0 ]
85
+ if repo in repo_python_files :
86
+ repo_python_files [repo ].append (file_path )
87
+
83
88
mypy_command = "mypy"
84
89
85
90
extra_args = ["--check-untyped-defs" ,
@@ -98,8 +103,14 @@ if args.quick:
98
103
extra_args .append ("--quick" )
99
104
100
105
# run mypy
101
- if python_files :
102
- rc = subprocess .call ([mypy_command ] + extra_args + python_files )
103
- sys .exit (rc )
104
- else :
105
- print ("There are no files to run mypy on." )
106
+ status = 0
107
+ for repo , python_files in repo_python_files .items ():
108
+ print ("Running mypy for `{}`." .format (repo ))
109
+ if python_files :
110
+ print (python_files )
111
+ result = subprocess .call ([mypy_command ] + extra_args + python_files )
112
+ if result != 0 :
113
+ status = result
114
+ else :
115
+ print ("There are no files to run mypy on." )
116
+ sys .exit (status )
0 commit comments