From 1624354f33bf0a33f0e715ba1ca391ae0154ad19 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 15:12:36 -0500 Subject: Use CompileCheckMode enum There were a ton of naked strings with TODOs telling us to use the enum. --- mesonbuild/compilers/mixins/emscripten.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mesonbuild/compilers/mixins/emscripten.py') diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py index 22b7655..f95e63f 100644 --- a/mesonbuild/compilers/mixins/emscripten.py +++ b/mesonbuild/compilers/mixins/emscripten.py @@ -22,6 +22,7 @@ from ... import coredata from ... import mesonlib from ...mesonlib import OptionKey from ...mesonlib import LibType +from mesonbuild.compilers.compilers import CompileCheckMode if T.TYPE_CHECKING: from ...environment import Environment @@ -46,14 +47,14 @@ def wrap_js_includes(args: T.List[str]) -> T.List[str]: class EmscriptenMixin(Compiler): - def _get_compile_output(self, dirname: str, mode: str) -> str: + def _get_compile_output(self, dirname: str, mode: CompileCheckMode) -> str: # In pre-processor mode, the output is sent to stdout and discarded - if mode == 'preprocess': + if mode == CompileCheckMode.PREPROCESS: return None # Unlike sane toolchains, emcc infers the kind of output from its name. # This is the only reason why this method is overridden; compiler tests # do not work well with the default exe/obj suffices. - if mode == 'link': + if mode == CompileCheckMode.LINK: suffix = 'js' else: suffix = 'o' -- cgit v1.1 From d4bcf05c39e650d9651b5f2c60e7c12d59367e9c Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:47:12 -0500 Subject: Annotate naked fundamental Python types Although mypy wasn't complaining, pyright was. --- mesonbuild/compilers/mixins/emscripten.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/mixins/emscripten.py') diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py index f95e63f..a07cff3 100644 --- a/mesonbuild/compilers/mixins/emscripten.py +++ b/mesonbuild/compilers/mixins/emscripten.py @@ -37,7 +37,7 @@ else: def wrap_js_includes(args: T.List[str]) -> T.List[str]: - final_args = [] + final_args: T.List[str] = [] for i in args: if i.endswith('.js') and not i.startswith('-'): final_args += ['--js-library', i] -- cgit v1.1 From 9e8a034ade51d45cd43268b38c15a73786e15d05 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:50:50 -0500 Subject: Fix the typing around Compiler._get_compile_output() This function says it returns a string, but was returning None in some cases. --- mesonbuild/compilers/mixins/emscripten.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mesonbuild/compilers/mixins/emscripten.py') diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py index a07cff3..fef22b9 100644 --- a/mesonbuild/compilers/mixins/emscripten.py +++ b/mesonbuild/compilers/mixins/emscripten.py @@ -48,9 +48,7 @@ def wrap_js_includes(args: T.List[str]) -> T.List[str]: class EmscriptenMixin(Compiler): def _get_compile_output(self, dirname: str, mode: CompileCheckMode) -> str: - # In pre-processor mode, the output is sent to stdout and discarded - if mode == CompileCheckMode.PREPROCESS: - return None + assert mode != CompileCheckMode.PREPROCESS, 'In pre-processor mode, the output is sent to stdout and discarded' # Unlike sane toolchains, emcc infers the kind of output from its name. # This is the only reason why this method is overridden; compiler tests # do not work well with the default exe/obj suffices. -- cgit v1.1