run_mypy: avoid type-checking tools against every possible python version

pull/12564/head
Eli Schwartz 1 year ago committed by Xavier Claessens
parent 739bdef431
commit cf64e062bb
  1. 11
      run_mypy.py

@ -69,7 +69,8 @@ modules = [
'mesonbuild/mtest.py',
'mesonbuild/optinterpreter.py',
'mesonbuild/programs.py',
]
additional = [
'run_mypy.py',
'run_project_tests.py',
'run_single_test.py',
@ -115,23 +116,29 @@ def main() -> int:
print('\x1bc', end='', flush=True)
to_check = [] # type: T.List[str]
additional_to_check = [] # type: T.List[str]
if opts.files:
for f in opts.files:
if f in modules:
to_check.append(f)
elif any(f.startswith(i) for i in modules):
to_check.append(f)
elif f in additional:
additional_to_check.append(f)
elif any(f.startswith(i) for i in additional):
additional_to_check.append(f)
else:
if not opts.quiet:
print(f'skipping {f!r} because it is not yet typed')
else:
to_check.extend(modules)
additional_to_check.extend(additional)
if to_check:
command = [opts.mypy] if opts.mypy else [sys.executable, '-m', 'mypy']
if not opts.quiet:
print('Running mypy (this can take some time) ...')
retcode = subprocess.run(command + args + to_check, cwd=root).returncode
retcode = subprocess.run(command + args + to_check + additional_to_check, cwd=root).returncode
if opts.allver and retcode == 0:
for minor in range(7, sys.version_info[1]):
if not opts.quiet:

Loading…
Cancel
Save