Skip to content

Commit f39decb

Browse files
jnsnowkevmw
authored andcommitted
iotests/linters: check mypy files all at once
We can circumvent the '__main__' redefinition problem by passing --scripts-are-modules. Take mypy out of the loop per-filename and check everything in one go: it's quite a bit faster. Signed-off-by: John Snow <[email protected]> Reviewed-by: Hanna Reitz <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Message-Id: <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent af6d4c5 commit f39decb

File tree

1 file changed

+21
-25
lines changed
  • tests/qemu-iotests

1 file changed

+21
-25
lines changed

tests/qemu-iotests/297

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,28 @@ def run_linters():
7474
print('=== mypy ===')
7575
sys.stdout.flush()
7676

77-
# We have to call mypy separately for each file. Otherwise, it
78-
# will interpret all given files as belonging together (i.e., they
79-
# may not both define the same classes, etc.; most notably, they
80-
# must not both define the __main__ module).
8177
env['MYPYPATH'] = env['PYTHONPATH']
82-
for filename in files:
83-
p = subprocess.run(('mypy',
84-
'--warn-unused-configs',
85-
'--disallow-subclassing-any',
86-
'--disallow-any-generics',
87-
'--disallow-incomplete-defs',
88-
'--disallow-untyped-decorators',
89-
'--no-implicit-optional',
90-
'--warn-redundant-casts',
91-
'--warn-unused-ignores',
92-
'--no-implicit-reexport',
93-
'--namespace-packages',
94-
filename),
95-
env=env,
96-
check=False,
97-
stdout=subprocess.PIPE,
98-
stderr=subprocess.STDOUT,
99-
universal_newlines=True)
100-
101-
if p.returncode != 0:
102-
print(p.stdout)
78+
p = subprocess.run(('mypy',
79+
'--warn-unused-configs',
80+
'--disallow-subclassing-any',
81+
'--disallow-any-generics',
82+
'--disallow-incomplete-defs',
83+
'--disallow-untyped-decorators',
84+
'--no-implicit-optional',
85+
'--warn-redundant-casts',
86+
'--warn-unused-ignores',
87+
'--no-implicit-reexport',
88+
'--namespace-packages',
89+
'--scripts-are-modules',
90+
*files),
91+
env=env,
92+
check=False,
93+
stdout=subprocess.PIPE,
94+
stderr=subprocess.STDOUT,
95+
universal_newlines=True)
96+
97+
if p.returncode != 0:
98+
print(p.stdout)
10399

104100

105101
for linter in ('pylint-3', 'mypy'):

0 commit comments

Comments
 (0)