diff options
author | Tristan Partin <tristan@partin.io> | 2023-07-12 17:50:50 -0500 |
---|---|---|
committer | Tristan Partin <tristan@partin.io> | 2023-07-12 18:56:06 -0500 |
commit | 9e8a034ade51d45cd43268b38c15a73786e15d05 (patch) | |
tree | 7610d800075efefb6cf02711888dbc475d47315b | |
parent | d4bcf05c39e650d9651b5f2c60e7c12d59367e9c (diff) | |
download | meson-9e8a034ade51d45cd43268b38c15a73786e15d05.zip meson-9e8a034ade51d45cd43268b38c15a73786e15d05.tar.gz meson-9e8a034ade51d45cd43268b38c15a73786e15d05.tar.bz2 |
Fix the typing around Compiler._get_compile_output()
This function says it returns a string, but was returning None in some
cases.
-rw-r--r-- | mesonbuild/compilers/compilers.py | 10 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/emscripten.py | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 56ed2d5..7873ea8 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -800,9 +800,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): return self.linker.has_multi_arguments(args, env) 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' # Extension only matters if running results; '.exe' is # guaranteed to be executable on every platform. if mode == CompileCheckMode.LINK: @@ -832,6 +830,10 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): *, mode: CompileCheckMode = CompileCheckMode.LINK, want_output: bool = False, temp_dir: T.Optional[str] = None) -> T.Iterator[T.Optional[CompileResult]]: # TODO: there isn't really any reason for this to be a contextmanager + + if mode == CompileCheckMode.PREPROCESS: + assert not want_output, 'In pre-processor mode, the output is sent to stdout and discarded' + if extra_args is None: extra_args = [] @@ -858,8 +860,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): commands.append(srcname) # Preprocess mode outputs to stdout, so no output args - output = self._get_compile_output(tmpdirname, mode) if mode != CompileCheckMode.PREPROCESS: + output = self._get_compile_output(tmpdirname, mode) commands += self.get_output_args(output) commands.extend(self.get_compiler_args_for_mode(CompileCheckMode(mode))) 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. |