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