From ce042f318e56f94afca7b92364728e02d068b30e Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Fri, 28 Aug 2020 18:01:41 +0200 Subject: typing: Add run_mypy.py for easier mypy invocation --- run_mypy.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 run_mypy.py (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py new file mode 100755 index 0000000..68fa344 --- /dev/null +++ b/run_mypy.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 + +import sys +import subprocess +from pathlib import Path +import typing as T + +normal_modules = [ + 'mesonbuild/interpreterbase.py', + 'mesonbuild/mtest.py', + 'mesonbuild/minit.py', + 'mesonbuild/mintro.py', + 'mesonbuild/mparser.py', + 'mesonbuild/msetup.py', + 'mesonbuild/ast', + 'mesonbuild/wrap', + 'tools', + 'mesonbuild/modules/fs.py', + 'mesonbuild/dependencies/boost.py', + 'mesonbuild/dependencies/mpi.py', + 'mesonbuild/dependencies/hdf5.py', + 'mesonbuild/compilers/mixins/intel.py', + 'mesonbuild/mlog.py', + 'mesonbuild/mcompile.py', + 'mesonbuild/mesonlib.py', + 'mesonbuild/arglist.py', + # 'mesonbuild/envconfig.py', +] + +strict_modules = [ + 'mesonbuild/interpreterbase.py', + # 'mesonbuild/mesonlib.py', + 'mesonbuild/mlog.py', + 'mesonbuild/ast', +] + +normal_args = ['--follow-imports=skip'] +strict_args = normal_args + [ + '--warn-redundant-casts', + '--warn-unused-ignores', + '--warn-return-any', + # '--warn-unreachable', + '--disallow-untyped-calls', + '--disallow-untyped-defs', + '--disallow-incomplete-defs', + '--disallow-untyped-decorators', + # '--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: + try: + import mypy + except ImportError: + print('Failed import mypy') + sys.exit(1) + +def main() -> int: + res = 0 + check_mypy() + + print('Running normal mypy check...') + res += run_mypy(normal_args, normal_modules) + + print('\n\nRunning struct mypy check...') + res += run_mypy(strict_args, strict_modules) + + return res + +if __name__ == '__main__': + sys.exit(main()) -- cgit v1.1 From bb09ca9ad551e00780dbd6a12ae1619859d4bc6a Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Fri, 28 Aug 2020 19:29:20 +0200 Subject: typing: fully annotate mesonlib.py --- run_mypy.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 68fa344..e9b8229 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -2,6 +2,7 @@ import sys import subprocess +import argparse from pathlib import Path import typing as T @@ -29,9 +30,10 @@ normal_modules = [ strict_modules = [ 'mesonbuild/interpreterbase.py', - # 'mesonbuild/mesonlib.py', + 'mesonbuild/mesonlib.py', 'mesonbuild/mlog.py', 'mesonbuild/ast', + 'run_mypy.py', ] normal_args = ['--follow-imports=skip'] @@ -44,6 +46,8 @@ strict_args = normal_args + [ '--disallow-untyped-defs', '--disallow-incomplete-defs', '--disallow-untyped-decorators', + '--no-implicit-optional', + '--strict-equality', # '--disallow-any-expr', # '--disallow-any-decorated', # '--disallow-any-explicit', @@ -70,6 +74,14 @@ def main() -> int: res = 0 check_mypy() + parser = argparse.ArgumentParser(description='Process some integers.') + parser.add_argument('-p', '--pretty', action='store_true', help='pretty print mypy errors') + + args = parser.parse_args() + if args.pretty: + normal_args.append('--pretty') + strict_args.append('--pretty') + print('Running normal mypy check...') res += run_mypy(normal_args, normal_modules) -- cgit v1.1 From fb9738b8c7dd1a900898a850b22810c5370fd9e5 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Fri, 28 Aug 2020 19:48:00 +0200 Subject: typing: fully annotate mparser.py --- run_mypy.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index e9b8229..4e56168 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -30,9 +30,11 @@ normal_modules = [ strict_modules = [ 'mesonbuild/interpreterbase.py', + 'mesonbuild/mparser.py', 'mesonbuild/mesonlib.py', 'mesonbuild/mlog.py', 'mesonbuild/ast', + # 'mesonbuild/wrap', 'run_mypy.py', ] -- cgit v1.1 From 449dd8e72a3ccc4c6f7ec70169515784cd687a2c Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Fri, 28 Aug 2020 21:23:10 +0200 Subject: typing: fully annotate wrap --- run_mypy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 4e56168..aca42da 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -34,7 +34,7 @@ strict_modules = [ 'mesonbuild/mesonlib.py', 'mesonbuild/mlog.py', 'mesonbuild/ast', - # 'mesonbuild/wrap', + 'mesonbuild/wrap', 'run_mypy.py', ] -- cgit v1.1 From 0d57e307b2fea541a9ee368873431fe224e5c982 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Fri, 28 Aug 2020 21:40:51 +0200 Subject: typing: fully annotate tools --- run_mypy.py | 1 + 1 file changed, 1 insertion(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index aca42da..7f8f23d 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -36,6 +36,7 @@ strict_modules = [ 'mesonbuild/ast', 'mesonbuild/wrap', 'run_mypy.py', + 'tools', ] normal_args = ['--follow-imports=skip'] -- cgit v1.1 From a4f4379c44c7f13bc9e44bc01504077af1f3a338 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sat, 29 Aug 2020 21:23:43 +0200 Subject: typing: fully annotate scripts --- run_mypy.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 7f8f23d..5e26ac1 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -15,6 +15,7 @@ normal_modules = [ 'mesonbuild/msetup.py', 'mesonbuild/ast', 'mesonbuild/wrap', + 'mesonbuild/scripts', 'tools', 'mesonbuild/modules/fs.py', 'mesonbuild/dependencies/boost.py', @@ -35,6 +36,7 @@ strict_modules = [ 'mesonbuild/mlog.py', 'mesonbuild/ast', 'mesonbuild/wrap', + 'mesonbuild/scripts', 'run_mypy.py', 'tools', ] -- cgit v1.1 From 1217cf9a3bf7a49b68539ea1649ad5d8289ca5d1 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 12:59:56 +0200 Subject: typing: fully annotate boost and hdf5 deps --- run_mypy.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 5e26ac1..71b6727 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -18,6 +18,7 @@ normal_modules = [ 'mesonbuild/scripts', 'tools', 'mesonbuild/modules/fs.py', + # 'mesonbuild/dependencies/base.py', 'mesonbuild/dependencies/boost.py', 'mesonbuild/dependencies/mpi.py', 'mesonbuild/dependencies/hdf5.py', @@ -37,6 +38,8 @@ strict_modules = [ 'mesonbuild/ast', 'mesonbuild/wrap', 'mesonbuild/scripts', + 'mesonbuild/dependencies/boost.py', + 'mesonbuild/dependencies/hdf5.py', 'run_mypy.py', 'tools', ] -- cgit v1.1 From 3dbfe8f75a17966917879e2be6037b262d807bac Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 13:11:24 +0200 Subject: typing: fully annotate arglist --- run_mypy.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 71b6727..c7d44b6 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -40,6 +40,8 @@ strict_modules = [ 'mesonbuild/scripts', 'mesonbuild/dependencies/boost.py', 'mesonbuild/dependencies/hdf5.py', + 'mesonbuild/compilers/mixins/intel.py', + 'mesonbuild/arglist.py', 'run_mypy.py', 'tools', ] -- cgit v1.1 From 6b1b995b32a867614535ba1d1c80844b273fc053 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 13:15:09 +0200 Subject: typing: fully annotate fs module --- run_mypy.py | 1 + 1 file changed, 1 insertion(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index c7d44b6..3369b1a 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -38,6 +38,7 @@ strict_modules = [ 'mesonbuild/ast', 'mesonbuild/wrap', 'mesonbuild/scripts', + 'mesonbuild/modules/fs.py', 'mesonbuild/dependencies/boost.py', 'mesonbuild/dependencies/hdf5.py', 'mesonbuild/compilers/mixins/intel.py', -- cgit v1.1 From c637b913c94817c81e9a35287b995741a7089413 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 13:26:41 +0200 Subject: typing: fully annotate mcompile, minit, and msetup --- run_mypy.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 3369b1a..3845732 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -32,7 +32,10 @@ normal_modules = [ strict_modules = [ 'mesonbuild/interpreterbase.py', + 'mesonbuild/minit.py', 'mesonbuild/mparser.py', + 'mesonbuild/msetup.py', + 'mesonbuild/mcompile.py', 'mesonbuild/mesonlib.py', 'mesonbuild/mlog.py', 'mesonbuild/ast', -- cgit v1.1 From 0490372449251fc2720748a0c58fb1bbdb5ca28f Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 14:55:52 +0200 Subject: typing: fully annotate mintro and mtest --- run_mypy.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 3845732..e2b0415 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -32,7 +32,9 @@ normal_modules = [ strict_modules = [ 'mesonbuild/interpreterbase.py', + 'mesonbuild/mtest.py', 'mesonbuild/minit.py', + 'mesonbuild/mintro.py', 'mesonbuild/mparser.py', 'mesonbuild/msetup.py', 'mesonbuild/mcompile.py', -- cgit v1.1 From ca1878ffb5ba5f72dcb44ca567d48a3a0a048f1f Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 15:34:33 +0200 Subject: typing: fix envconfig typing --- run_mypy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index e2b0415..9851b5d 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -27,7 +27,7 @@ normal_modules = [ 'mesonbuild/mcompile.py', 'mesonbuild/mesonlib.py', 'mesonbuild/arglist.py', - # 'mesonbuild/envconfig.py', + 'mesonbuild/envconfig.py', ] strict_modules = [ -- cgit v1.1 From 5deb33b03c221634829e5ac57d6a6bd77453759c Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 30 Aug 2020 15:58:23 +0200 Subject: typing: update run_mypy and mypy.ini --- run_mypy.py | 98 ++++++++++++++++--------------------------------------------- 1 file changed, 26 insertions(+), 72 deletions(-) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 9851b5d..759d667 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -6,79 +6,34 @@ import argparse from pathlib import Path import typing as T -normal_modules = [ - 'mesonbuild/interpreterbase.py', - 'mesonbuild/mtest.py', - 'mesonbuild/minit.py', - 'mesonbuild/mintro.py', - 'mesonbuild/mparser.py', - 'mesonbuild/msetup.py', +modules = [ + # fully typed submodules 'mesonbuild/ast', - 'mesonbuild/wrap', 'mesonbuild/scripts', - 'tools', - 'mesonbuild/modules/fs.py', - # 'mesonbuild/dependencies/base.py', + 'mesonbuild/wrap', + + # specific files + 'mesonbuild/arglist.py', + # 'mesonbuild/compilers/mixins/intel.py', 'mesonbuild/dependencies/boost.py', - 'mesonbuild/dependencies/mpi.py', 'mesonbuild/dependencies/hdf5.py', - 'mesonbuild/compilers/mixins/intel.py', - 'mesonbuild/mlog.py', - 'mesonbuild/mcompile.py', - 'mesonbuild/mesonlib.py', - 'mesonbuild/arglist.py', + 'mesonbuild/dependencies/mpi.py', 'mesonbuild/envconfig.py', -] - -strict_modules = [ 'mesonbuild/interpreterbase.py', - 'mesonbuild/mtest.py', - 'mesonbuild/minit.py', - 'mesonbuild/mintro.py', - 'mesonbuild/mparser.py', - 'mesonbuild/msetup.py', 'mesonbuild/mcompile.py', 'mesonbuild/mesonlib.py', + 'mesonbuild/minit.py', + 'mesonbuild/mintro.py', 'mesonbuild/mlog.py', - 'mesonbuild/ast', - 'mesonbuild/wrap', - 'mesonbuild/scripts', 'mesonbuild/modules/fs.py', - 'mesonbuild/dependencies/boost.py', - 'mesonbuild/dependencies/hdf5.py', - 'mesonbuild/compilers/mixins/intel.py', - 'mesonbuild/arglist.py', - 'run_mypy.py', - 'tools', -] + 'mesonbuild/mparser.py', + 'mesonbuild/msetup.py', + 'mesonbuild/mtest.py', -normal_args = ['--follow-imports=skip'] -strict_args = normal_args + [ - '--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', + 'run_mypy.py', + 'tools' ] -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: try: import mypy @@ -87,24 +42,23 @@ def check_mypy() -> None: sys.exit(1) def main() -> int: - res = 0 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') - args = parser.parse_args() - if args.pretty: - normal_args.append('--pretty') - strict_args.append('--pretty') + opts = parser.parse_args() + if opts.pretty: + args.append('--pretty') - print('Running normal mypy check...') - res += run_mypy(normal_args, normal_modules) - - print('\n\nRunning struct mypy check...') - res += run_mypy(strict_args, strict_modules) - - return res + p = subprocess.run( + [sys.executable, '-m', 'mypy'] + args + modules, + cwd=root, + ) + return p.returncode if __name__ == '__main__': sys.exit(main()) -- cgit v1.1 From 23818fc5a389c49e2673f79af2c90d9d56b1aaf0 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 1 Sep 2020 14:28:08 +0200 Subject: typing: more fixes --- run_mypy.py | 1 + 1 file changed, 1 insertion(+) (limited to 'run_mypy.py') diff --git a/run_mypy.py b/run_mypy.py index 759d667..d5ec55d 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -15,6 +15,7 @@ modules = [ # 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', -- cgit v1.1