6
6
from pathlib import Path
7
7
import typing as T
8
8
9
- normal_modules = [
10
- 'mesonbuild/interpreterbase.py' ,
11
- 'mesonbuild/mtest.py' ,
12
- 'mesonbuild/minit.py' ,
13
- 'mesonbuild/mintro.py' ,
14
- 'mesonbuild/mparser.py' ,
15
- 'mesonbuild/msetup.py' ,
9
+ modules = [
10
+ # fully typed submodules
16
11
'mesonbuild/ast' ,
17
- 'mesonbuild/wrap' ,
18
12
'mesonbuild/scripts' ,
19
- 'tools' ,
20
- 'mesonbuild/modules/fs.py' ,
21
- # 'mesonbuild/dependencies/base.py',
13
+ 'mesonbuild/wrap' ,
14
+
15
+ # specific files
16
+ 'mesonbuild/arglist.py' ,
17
+ # 'mesonbuild/compilers/mixins/intel.py',
22
18
'mesonbuild/dependencies/boost.py' ,
23
- 'mesonbuild/dependencies/mpi.py' ,
24
19
'mesonbuild/dependencies/hdf5.py' ,
25
- 'mesonbuild/compilers/mixins/intel.py' ,
26
- 'mesonbuild/mlog.py' ,
27
- 'mesonbuild/mcompile.py' ,
28
- 'mesonbuild/mesonlib.py' ,
29
- 'mesonbuild/arglist.py' ,
20
+ 'mesonbuild/dependencies/mpi.py' ,
30
21
'mesonbuild/envconfig.py' ,
31
- ]
32
-
33
- strict_modules = [
34
22
'mesonbuild/interpreterbase.py' ,
35
- 'mesonbuild/mtest.py' ,
36
- 'mesonbuild/minit.py' ,
37
- 'mesonbuild/mintro.py' ,
38
- 'mesonbuild/mparser.py' ,
39
- 'mesonbuild/msetup.py' ,
40
23
'mesonbuild/mcompile.py' ,
41
24
'mesonbuild/mesonlib.py' ,
25
+ 'mesonbuild/minit.py' ,
26
+ 'mesonbuild/mintro.py' ,
42
27
'mesonbuild/mlog.py' ,
43
- 'mesonbuild/ast' ,
44
- 'mesonbuild/wrap' ,
45
- 'mesonbuild/scripts' ,
46
28
'mesonbuild/modules/fs.py' ,
47
- 'mesonbuild/dependencies/boost.py' ,
48
- 'mesonbuild/dependencies/hdf5.py' ,
49
- 'mesonbuild/compilers/mixins/intel.py' ,
50
- 'mesonbuild/arglist.py' ,
51
- 'run_mypy.py' ,
52
- 'tools' ,
53
- ]
29
+ 'mesonbuild/mparser.py' ,
30
+ 'mesonbuild/msetup.py' ,
31
+ 'mesonbuild/mtest.py' ,
54
32
55
- normal_args = ['--follow-imports=skip' ]
56
- strict_args = normal_args + [
57
- '--warn-redundant-casts' ,
58
- '--warn-unused-ignores' ,
59
- '--warn-return-any' ,
60
- # '--warn-unreachable',
61
- '--disallow-untyped-calls' ,
62
- '--disallow-untyped-defs' ,
63
- '--disallow-incomplete-defs' ,
64
- '--disallow-untyped-decorators' ,
65
- '--no-implicit-optional' ,
66
- '--strict-equality' ,
67
- # '--disallow-any-expr',
68
- # '--disallow-any-decorated',
69
- # '--disallow-any-explicit',
70
- # '--disallow-any-generics',
71
- # '--disallow-subclassing-any',
33
+ 'run_mypy.py' ,
34
+ 'tools'
72
35
]
73
36
74
- def run_mypy (opts : T .List [str ], modules : T .List [str ]) -> int :
75
- root = Path (__file__ ).absolute ().parent
76
- p = subprocess .run (
77
- [sys .executable , '-m' , 'mypy' ] + opts + modules ,
78
- cwd = root ,
79
- )
80
- return p .returncode
81
-
82
37
def check_mypy () -> None :
83
38
try :
84
39
import mypy
@@ -87,24 +42,23 @@ def check_mypy() -> None:
87
42
sys .exit (1 )
88
43
89
44
def main () -> int :
90
- res = 0
91
45
check_mypy ()
92
46
47
+ root = Path (__file__ ).absolute ().parent
48
+ args = [] # type: T.List[str]
49
+
93
50
parser = argparse .ArgumentParser (description = 'Process some integers.' )
94
51
parser .add_argument ('-p' , '--pretty' , action = 'store_true' , help = 'pretty print mypy errors' )
95
52
96
- args = parser .parse_args ()
97
- if args .pretty :
98
- normal_args .append ('--pretty' )
99
- strict_args .append ('--pretty' )
53
+ opts = parser .parse_args ()
54
+ if opts .pretty :
55
+ args .append ('--pretty' )
100
56
101
- print ('Running normal mypy check...' )
102
- res += run_mypy (normal_args , normal_modules )
103
-
104
- print ('\n \n Running struct mypy check...' )
105
- res += run_mypy (strict_args , strict_modules )
106
-
107
- return res
57
+ p = subprocess .run (
58
+ [sys .executable , '-m' , 'mypy' ] + args + modules ,
59
+ cwd = root ,
60
+ )
61
+ return p .returncode
108
62
109
63
if __name__ == '__main__' :
110
64
sys .exit (main ())
0 commit comments