diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-09-17 12:13:05 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-09-24 12:14:13 -0700 |
commit | 1e93d2875e77e6465f985dfcdef6b355a19c7d7c (patch) | |
tree | ad36c30616dc7c28bb38cbee3e075014a5f1683c | |
parent | 04a98baafb6c779e15d423505ea1e363e61944a8 (diff) | |
download | meson-1e93d2875e77e6465f985dfcdef6b355a19c7d7c.zip meson-1e93d2875e77e6465f985dfcdef6b355a19c7d7c.tar.gz meson-1e93d2875e77e6465f985dfcdef6b355a19c7d7c.tar.bz2 |
compilers/mixins/emscripten: make type safe
-rw-r--r-- | mesonbuild/compilers/mixins/emscripten.py | 15 | ||||
-rwxr-xr-x | run_mypy.py | 1 |
2 files changed, 12 insertions, 4 deletions
diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py index 08b2205..f15db40 100644 --- a/mesonbuild/compilers/mixins/emscripten.py +++ b/mesonbuild/compilers/mixins/emscripten.py @@ -20,12 +20,17 @@ import typing as T from ... import coredata if T.TYPE_CHECKING: - from ..environment import Environment + from ...envconfig import MachineChoice + from ...environment import Environment class EmscriptenMixin: - def _get_compile_output(self, dirname, mode): + if T.TYPE_CHECKING: + for_machine = MachineChoice.HOST + language = '' + + def _get_compile_output(self, dirname: str, mode: str) -> str: # In pre-processor mode, the output is sent to stdout and discarded if mode == 'preprocess': return None @@ -48,8 +53,10 @@ class EmscriptenMixin: args.extend(['-s', 'PTHREAD_POOL_SIZE={}'.format(count)]) return args - def get_options(self): - opts = super().get_options() + def get_options(self) -> 'coredata.OptionDictType': + # Mypy and co-operative inheritance + _opts = super().get_options() # type: ignore + opts = T.cast('coredata.OptionDictType', _opts) opts.update({ '{}_thread_count'.format(self.language): coredata.UserIntegerOption( 'Number of threads to use in web assembly, set to 0 to disable', diff --git a/run_mypy.py b/run_mypy.py index 8837094..adffd83 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -22,6 +22,7 @@ modules = [ 'mesonbuild/compilers/mixins/clike.py', 'mesonbuild/compilers/mixins/compcert.py', 'mesonbuild/compilers/mixins/elbrus.py', + 'mesonbuild/compilers/mixins/emscripten.py', 'mesonbuild/compilers/mixins/gnu.py', # 'mesonbuild/compilers/mixins/intel.py', # 'mesonbuild/coredata.py', |