|
|
@ -6,79 +6,34 @@ import argparse |
|
|
|
from pathlib import Path |
|
|
|
from pathlib import Path |
|
|
|
import typing as T |
|
|
|
import typing as T |
|
|
|
|
|
|
|
|
|
|
|
normal_modules = [ |
|
|
|
modules = [ |
|
|
|
'mesonbuild/interpreterbase.py', |
|
|
|
# fully typed submodules |
|
|
|
'mesonbuild/mtest.py', |
|
|
|
|
|
|
|
'mesonbuild/minit.py', |
|
|
|
|
|
|
|
'mesonbuild/mintro.py', |
|
|
|
|
|
|
|
'mesonbuild/mparser.py', |
|
|
|
|
|
|
|
'mesonbuild/msetup.py', |
|
|
|
|
|
|
|
'mesonbuild/ast', |
|
|
|
'mesonbuild/ast', |
|
|
|
'mesonbuild/wrap', |
|
|
|
|
|
|
|
'mesonbuild/scripts', |
|
|
|
'mesonbuild/scripts', |
|
|
|
'tools', |
|
|
|
'mesonbuild/wrap', |
|
|
|
'mesonbuild/modules/fs.py', |
|
|
|
|
|
|
|
# 'mesonbuild/dependencies/base.py', |
|
|
|
# specific files |
|
|
|
|
|
|
|
'mesonbuild/arglist.py', |
|
|
|
|
|
|
|
# 'mesonbuild/compilers/mixins/intel.py', |
|
|
|
'mesonbuild/dependencies/boost.py', |
|
|
|
'mesonbuild/dependencies/boost.py', |
|
|
|
'mesonbuild/dependencies/mpi.py', |
|
|
|
|
|
|
|
'mesonbuild/dependencies/hdf5.py', |
|
|
|
'mesonbuild/dependencies/hdf5.py', |
|
|
|
'mesonbuild/compilers/mixins/intel.py', |
|
|
|
'mesonbuild/dependencies/mpi.py', |
|
|
|
'mesonbuild/mlog.py', |
|
|
|
|
|
|
|
'mesonbuild/mcompile.py', |
|
|
|
|
|
|
|
'mesonbuild/mesonlib.py', |
|
|
|
|
|
|
|
'mesonbuild/arglist.py', |
|
|
|
|
|
|
|
'mesonbuild/envconfig.py', |
|
|
|
'mesonbuild/envconfig.py', |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strict_modules = [ |
|
|
|
|
|
|
|
'mesonbuild/interpreterbase.py', |
|
|
|
'mesonbuild/interpreterbase.py', |
|
|
|
'mesonbuild/mtest.py', |
|
|
|
|
|
|
|
'mesonbuild/minit.py', |
|
|
|
|
|
|
|
'mesonbuild/mintro.py', |
|
|
|
|
|
|
|
'mesonbuild/mparser.py', |
|
|
|
|
|
|
|
'mesonbuild/msetup.py', |
|
|
|
|
|
|
|
'mesonbuild/mcompile.py', |
|
|
|
'mesonbuild/mcompile.py', |
|
|
|
'mesonbuild/mesonlib.py', |
|
|
|
'mesonbuild/mesonlib.py', |
|
|
|
|
|
|
|
'mesonbuild/minit.py', |
|
|
|
|
|
|
|
'mesonbuild/mintro.py', |
|
|
|
'mesonbuild/mlog.py', |
|
|
|
'mesonbuild/mlog.py', |
|
|
|
'mesonbuild/ast', |
|
|
|
|
|
|
|
'mesonbuild/wrap', |
|
|
|
|
|
|
|
'mesonbuild/scripts', |
|
|
|
|
|
|
|
'mesonbuild/modules/fs.py', |
|
|
|
'mesonbuild/modules/fs.py', |
|
|
|
'mesonbuild/dependencies/boost.py', |
|
|
|
'mesonbuild/mparser.py', |
|
|
|
'mesonbuild/dependencies/hdf5.py', |
|
|
|
'mesonbuild/msetup.py', |
|
|
|
'mesonbuild/compilers/mixins/intel.py', |
|
|
|
'mesonbuild/mtest.py', |
|
|
|
'mesonbuild/arglist.py', |
|
|
|
|
|
|
|
'run_mypy.py', |
|
|
|
|
|
|
|
'tools', |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
normal_args = ['--follow-imports=skip'] |
|
|
|
'run_mypy.py', |
|
|
|
strict_args = normal_args + [ |
|
|
|
'tools' |
|
|
|
'--warn-redundant-casts', |
|
|
|
|
|
|
|
'--warn-unused-ignores', |
|
|
|
|
|
|
|
'--warn-return-any', |
|
|
|
|
|
|
|
# '--warn-unreachable', |
|
|
|
|
|
|
|
'--disallow-untyped-calls', |
|
|
|
|
|
|
|
'--disallow-untyped-defs', |
|
|
|
|
|
|
|
'--disallow-incomplete-defs', |
|
|
|
|
|
|
|
'--disallow-untyped-decorators', |
|
|
|
|
|
|
|
'--no-implicit-optional', |
|
|
|
|
|
|
|
'--strict-equality', |
|
|
|
|
|
|
|
# '--disallow-any-expr', |
|
|
|
|
|
|
|
# '--disallow-any-decorated', |
|
|
|
|
|
|
|
# '--disallow-any-explicit', |
|
|
|
|
|
|
|
# '--disallow-any-generics', |
|
|
|
|
|
|
|
# '--disallow-subclassing-any', |
|
|
|
|
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
def run_mypy(opts: T.List[str], modules: T.List[str]) -> int: |
|
|
|
|
|
|
|
root = Path(__file__).absolute().parent |
|
|
|
|
|
|
|
p = subprocess.run( |
|
|
|
|
|
|
|
[sys.executable, '-m', 'mypy'] + opts + modules, |
|
|
|
|
|
|
|
cwd=root, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
return p.returncode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_mypy() -> None: |
|
|
|
def check_mypy() -> None: |
|
|
|
try: |
|
|
|
try: |
|
|
|
import mypy |
|
|
|
import mypy |
|
|
@ -87,24 +42,23 @@ def check_mypy() -> None: |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
def main() -> int: |
|
|
|
def main() -> int: |
|
|
|
res = 0 |
|
|
|
|
|
|
|
check_mypy() |
|
|
|
check_mypy() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root = Path(__file__).absolute().parent |
|
|
|
|
|
|
|
args = [] # type: T.List[str] |
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Process some integers.') |
|
|
|
parser = argparse.ArgumentParser(description='Process some integers.') |
|
|
|
parser.add_argument('-p', '--pretty', action='store_true', help='pretty print mypy errors') |
|
|
|
parser.add_argument('-p', '--pretty', action='store_true', help='pretty print mypy errors') |
|
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args() |
|
|
|
opts = parser.parse_args() |
|
|
|
if args.pretty: |
|
|
|
if opts.pretty: |
|
|
|
normal_args.append('--pretty') |
|
|
|
args.append('--pretty') |
|
|
|
strict_args.append('--pretty') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('Running normal mypy check...') |
|
|
|
p = subprocess.run( |
|
|
|
res += run_mypy(normal_args, normal_modules) |
|
|
|
[sys.executable, '-m', 'mypy'] + args + modules, |
|
|
|
|
|
|
|
cwd=root, |
|
|
|
print('\n\nRunning struct mypy check...') |
|
|
|
) |
|
|
|
res += run_mypy(strict_args, strict_modules) |
|
|
|
return p.returncode |
|
|
|
|
|
|
|
|
|
|
|
return res |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
sys.exit(main()) |
|
|
|
sys.exit(main()) |
|
|
|