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 /mesonbuild | |
parent | d08091756191981f1bd3c7741b412b95f965fe0a (diff) | |
download | meson-6e708208ddc870fefde92b22c031575c33bb243b.zip meson-6e708208ddc870fefde92b22c031575c33bb243b.tar.gz meson-6e708208ddc870fefde92b22c031575c33bb243b.tar.bz2 |
CI: add initial type annotation checking
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/minit.py | 2 | ||||
-rw-r--r-- | mesonbuild/msetup.py | 14 | ||||
-rw-r--r-- | mesonbuild/mtest.py | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index e89b4cf..79741e5 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -83,7 +83,7 @@ def create_sample(options): raise RuntimeError('Unreachable code') print(info_message) -def autodetect_options(options, sample=False): +def autodetect_options(options, sample: bool = False): if not options.name: options.name = Path().resolve().stem if not re.match('[a-zA-Z_][a-zA-Z0-9]*', options.name) and sample: diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index e06a803..eb3a964 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import typing import time import sys, stat import datetime @@ -96,11 +97,11 @@ class MesonApp: self.options = options - def has_build_file(self, dirname): + def has_build_file(self, dirname: str) -> bool: fname = os.path.join(dirname, environment.build_filename) return os.path.exists(fname) - def validate_core_dirs(self, dir1, dir2): + def validate_core_dirs(self, dir1: str, dir2: str) -> typing.Tuple[str, str]: if dir1 is None: if dir2 is None: if not os.path.exists('meson.build') and os.path.exists('../meson.build'): @@ -130,7 +131,7 @@ class MesonApp: return ndir2, ndir1 raise MesonException('Neither directory contains a build file %s.' % environment.build_filename) - def validate_dirs(self, dir1, dir2, reconfigure, wipe): + def validate_dirs(self, dir1: str, dir2: str, reconfigure: bool, wipe: bool) -> typing.Tuple[str, str]: (src_dir, build_dir) = self.validate_core_dirs(dir1, dir2) priv_dir = os.path.join(build_dir, 'meson-private/coredata.dat') if os.path.exists(priv_dir): @@ -142,12 +143,11 @@ class MesonApp: '\nIf build failures persist, run "meson setup --wipe" to rebuild from scratch\n' 'using the same options as passed when configuring the build.' '\nTo change option values, run "meson configure" instead.') - sys.exit(0) + raise SystemExit else: has_cmd_line_file = os.path.exists(coredata.get_cmd_line_file(build_dir)) if (wipe and not has_cmd_line_file) or (not wipe and reconfigure): - print('Directory does not contain a valid build tree:\n{}'.format(build_dir)) - sys.exit(1) + raise SystemExit('Directory does not contain a valid build tree:\n{}'.format(build_dir)) return src_dir, build_dir def generate(self): @@ -239,7 +239,7 @@ class MesonApp: os.unlink(cdf) raise -def run(options): +def run(options) -> int: coredata.parse_cmd_line_options(options) app = MesonApp(options) app.generate() diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 1f52eda..d9652da 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -533,7 +533,7 @@ class SingleTestRunner: # We don't want setsid() in gdb because gdb needs the # terminal in order to handle ^C and not show tcsetpgrp() # errors avoid not being able to use the terminal. - os.setsid() + os.setsid() # type: ignore p = subprocess.Popen(cmd, stdout=stdout, @@ -570,11 +570,11 @@ class SingleTestRunner: # killing a process and all its children so we need # to roll our own. if is_windows(): - subprocess.call(['taskkill', '/F', '/T', '/PID', str(p.pid)]) + subprocess.run(['taskkill', '/F', '/T', '/PID', str(p.pid)]) else: try: # Kill the process group that setsid() created. - os.killpg(p.pid, signal.SIGKILL) + os.killpg(p.pid, signal.SIGKILL) # type: ignore except ProcessLookupError: # Sometimes (e.g. with Wine) this happens. # There's nothing we can do (maybe the process |