Skip to content

Commit 5deb33b

Browse files
committed
typing: update run_mypy and mypy.ini
1 parent ca1878f commit 5deb33b

File tree

2 files changed

+48
-76
lines changed

2 files changed

+48
-76
lines changed

.mypy.ini

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
[mypy]
2-
strict_optional = False
3-
show_error_context = False
4-
show_column_numbers = True
5-
ignore_missing_imports = True
2+
strict_optional = False
3+
show_error_context = False
4+
show_column_numbers = True
5+
ignore_missing_imports = True
6+
7+
follow_imports = skip
8+
warn_redundant_casts = True
9+
warn_unused_ignores = True
10+
warn_return_any = True
11+
# warn_unreachable = True
12+
disallow_untyped_calls = True
13+
disallow_untyped_defs = True
14+
disallow_incomplete_defs = True
15+
disallow_untyped_decorators = True
16+
no_implicit_optional = True
17+
strict_equality = True
18+
check_untyped_defs = True
19+
# disallow_any_expr = True
20+
# disallow_any_decorated = True
21+
# disallow_any_explicit = True
22+
# disallow_any_generics = True
23+
# disallow_subclassing_any = True

run_mypy.py

+26-72
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,34 @@
66
from pathlib import Path
77
import typing as T
88

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
1611
'mesonbuild/ast',
17-
'mesonbuild/wrap',
1812
'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',
2218
'mesonbuild/dependencies/boost.py',
23-
'mesonbuild/dependencies/mpi.py',
2419
'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',
3021
'mesonbuild/envconfig.py',
31-
]
32-
33-
strict_modules = [
3422
'mesonbuild/interpreterbase.py',
35-
'mesonbuild/mtest.py',
36-
'mesonbuild/minit.py',
37-
'mesonbuild/mintro.py',
38-
'mesonbuild/mparser.py',
39-
'mesonbuild/msetup.py',
4023
'mesonbuild/mcompile.py',
4124
'mesonbuild/mesonlib.py',
25+
'mesonbuild/minit.py',
26+
'mesonbuild/mintro.py',
4227
'mesonbuild/mlog.py',
43-
'mesonbuild/ast',
44-
'mesonbuild/wrap',
45-
'mesonbuild/scripts',
4628
'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',
5432

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'
7235
]
7336

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-
8237
def check_mypy() -> None:
8338
try:
8439
import mypy
@@ -87,24 +42,23 @@ def check_mypy() -> None:
8742
sys.exit(1)
8843

8944
def main() -> int:
90-
res = 0
9145
check_mypy()
9246

47+
root = Path(__file__).absolute().parent
48+
args = [] # type: T.List[str]
49+
9350
parser = argparse.ArgumentParser(description='Process some integers.')
9451
parser.add_argument('-p', '--pretty', action='store_true', help='pretty print mypy errors')
9552

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')
10056

101-
print('Running normal mypy check...')
102-
res += run_mypy(normal_args, normal_modules)
103-
104-
print('\n\nRunning 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
10862

10963
if __name__ == '__main__':
11064
sys.exit(main())

0 commit comments

Comments
 (0)