diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-11-06 17:21:25 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-11-07 22:18:21 +0200 |
commit | 6e708208ddc870fefde92b22c031575c33bb243b (patch) | |
tree | 0eeac1c226d66cb8ce0315362cdcb5ae682d03f8 /tools | |
parent | d08091756191981f1bd3c7741b412b95f965fe0a (diff) | |
download | meson-6e708208ddc870fefde92b22c031575c33bb243b.zip meson-6e708208ddc870fefde92b22c031575c33bb243b.tar.gz meson-6e708208ddc870fefde92b22c031575c33bb243b.tar.bz2 |
CI: add initial type annotation checking
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/ac_converter.py | 14 | ||||
-rwxr-xr-x | tools/boost_names.py | 2 | ||||
-rwxr-xr-x | tools/dircondenser.py | 21 |
3 files changed, 20 insertions, 17 deletions
diff --git a/tools/ac_converter.py b/tools/ac_converter.py index 739c42c..a1969a9 100755 --- a/tools/ac_converter.py +++ b/tools/ac_converter.py @@ -389,9 +389,9 @@ with open(sys.argv[1]) as f: token = arr[1] if token in function_data: fdata = function_data[token] - functions.append((token, fdata[0], fdata[1])) + functions.append([token, fdata[0], fdata[1]]) elif token.startswith('HAVE_') and not token.endswith('_H'): - functions.append((token, )) + functions.append([token]) except Exception: pass @@ -427,12 +427,12 @@ endforeach # Convert function checks. print('check_functions = [') -for token in functions: - if len(token) == 3: - token, fdata0, fdata1 = token - print(" ['%s', '%s', '#include<%s>']," % (token, fdata0, fdata1)) +for tok in functions: + if len(tok) == 3: + tokstr, fdata0, fdata1 = tok + print(" ['%s', '%s', '#include<%s>']," % (tokstr, fdata0, fdata1)) else: - print('# check token', token) + print('# check token', tok) print(']\n') print('''foreach f : check_functions diff --git a/tools/boost_names.py b/tools/boost_names.py index d0e5444..af461d8 100755 --- a/tools/boost_names.py +++ b/tools/boost_names.py @@ -31,7 +31,7 @@ import json import re Module = collections.namedtuple('Module', ['dirname', 'name', 'libnames']) -Module.__repr__ = lambda self: str((self.dirname, self.name, self.libnames)) +Module.__repr__ = lambda self: str((self.dirname, self.name, self.libnames)) # type: ignore LIBS = 'libs' diff --git a/tools/dircondenser.py b/tools/dircondenser.py index 58c44a2..a3cdfdc 100755 --- a/tools/dircondenser.py +++ b/tools/dircondenser.py @@ -32,25 +32,28 @@ to this: This directory must be run from source root as it touches run_unittests.py. ''' -import os, sys, subprocess +import typing +import os +import sys +import subprocess from glob import glob -def get_entries(): +def get_entries() -> typing.List[typing.Tuple[int, str]]: entries = [] for e in glob('*'): if not os.path.isdir(e): - sys.exit('Current directory must not contain any files.') + raise SystemExit('Current directory must not contain any files.') (number, rest) = e.split(' ', 1) try: - number = int(number) + numstr = int(number) except ValueError: - sys.exit('Dir name %d does not start with a number.' % e) - entries.append((number, rest)) + raise SystemExit('Dir name {} does not start with a number.'.format(e)) + entries.append((numstr, rest)) entries.sort() return entries -def replace_source(sourcefile, replacements): +def replace_source(sourcefile: str, replacements: typing.List[typing.Tuple[str, str]]): with open(sourcefile, 'r') as f: contents = f.read() for old_name, new_name in replacements: @@ -58,7 +61,7 @@ def replace_source(sourcefile, replacements): with open(sourcefile, 'w') as f: f.write(contents) -def condense(dirname): +def condense(dirname: str): curdir = os.getcwd() os.chdir(dirname) entries = get_entries() @@ -77,6 +80,6 @@ def condense(dirname): if __name__ == '__main__': if len(sys.argv) != 1: - sys.exit('This script takes no arguments.') + raise SystemExit('This script takes no arguments.') for d in glob('test cases/*'): condense(d) |