diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-09-09 10:31:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 10:31:52 -0700 |
commit | 4c2d0eb9bcedefa3ef06a237a0502afbc581268b (patch) | |
tree | 1b08ca5fb0c93573409a7a8954e6e1905f8a5b10 /run_mypy.py | |
parent | 8d54b7bda30062569c981b50a85a175565a7c15a (diff) | |
parent | 057c77f7d08b3372e99065fb3f3cd37f16801a82 (diff) | |
download | meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.zip meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.tar.gz meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.tar.bz2 |
Merge pull request #7657 from mensinda/moreTyping
typing: Strict type annotations
Diffstat (limited to 'run_mypy.py')
-rwxr-xr-x | run_mypy.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/run_mypy.py b/run_mypy.py new file mode 100755 index 0000000..d5ec55d --- /dev/null +++ b/run_mypy.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import sys +import subprocess +import argparse +from pathlib import Path +import typing as T + +modules = [ + # fully typed submodules + 'mesonbuild/ast', + 'mesonbuild/scripts', + 'mesonbuild/wrap', + + # specific files + 'mesonbuild/arglist.py', + # 'mesonbuild/compilers/mixins/intel.py', + # 'mesonbuild/coredata.py', + 'mesonbuild/dependencies/boost.py', + 'mesonbuild/dependencies/hdf5.py', + 'mesonbuild/dependencies/mpi.py', + 'mesonbuild/envconfig.py', + 'mesonbuild/interpreterbase.py', + 'mesonbuild/mcompile.py', + 'mesonbuild/mesonlib.py', + 'mesonbuild/minit.py', + 'mesonbuild/mintro.py', + 'mesonbuild/mlog.py', + 'mesonbuild/modules/fs.py', + 'mesonbuild/mparser.py', + 'mesonbuild/msetup.py', + 'mesonbuild/mtest.py', + + 'run_mypy.py', + 'tools' +] + +def check_mypy() -> None: + try: + import mypy + except ImportError: + print('Failed import mypy') + sys.exit(1) + +def main() -> int: + check_mypy() + + root = Path(__file__).absolute().parent + args = [] # type: T.List[str] + + parser = argparse.ArgumentParser(description='Process some integers.') + parser.add_argument('-p', '--pretty', action='store_true', help='pretty print mypy errors') + + opts = parser.parse_args() + if opts.pretty: + args.append('--pretty') + + p = subprocess.run( + [sys.executable, '-m', 'mypy'] + args + modules, + cwd=root, + ) + return p.returncode + +if __name__ == '__main__': + sys.exit(main()) |