From 24edddb412dfa6cbf48d1c31b73d4d4903aa0fa0 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 18:15:27 -0500 Subject: [PATCH] Fix return type of debugfile functions It was returning None in some cases while being marked as returning string. --- mesonbuild/backend/ninjabackend.py | 2 +- mesonbuild/compilers/compilers.py | 2 +- mesonbuild/compilers/mixins/islinker.py | 4 ++-- mesonbuild/linkers/linkers.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 108aa7295..6ed1e46c4 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2797,7 +2797,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) else: return compiler.get_compile_debugfile_args(objfile, pch=False) - def get_link_debugfile_name(self, linker, target, outname): + def get_link_debugfile_name(self, linker, target, outname) -> T.Optional[str]: return linker.get_link_debugfile_name(outname) def get_link_debugfile_args(self, linker, target, outname): diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 4cbdb1fc9..cb8eae56a 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -921,7 +921,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]: return [] - def get_link_debugfile_name(self, targetfile: str) -> str: + def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]: return self.linker.get_debugfile_name(targetfile) def get_link_debugfile_args(self, targetfile: str) -> T.List[str]: diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py index 711e3e376..cfdd746b0 100644 --- a/mesonbuild/compilers/mixins/islinker.py +++ b/mesonbuild/compilers/mixins/islinker.py @@ -120,8 +120,8 @@ class BasicLinkerIsCompilerMixin(Compiler): def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]: return [] - def get_link_debugfile_name(self, targetfile: str) -> str: - return '' + def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]: + return None def thread_flags(self, env: 'Environment') -> T.List[str]: return [] diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py index 609308b2d..8f413c857 100644 --- a/mesonbuild/linkers/linkers.py +++ b/mesonbuild/linkers/linkers.py @@ -86,7 +86,7 @@ class StaticLinker: def native_args_to_unix(cls, args: T.List[str]) -> T.List[str]: return args[:] - def get_link_debugfile_name(self, targetfile: str) -> str: + def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]: return None def get_link_debugfile_args(self, targetfile: str) -> T.List[str]: @@ -428,7 +428,7 @@ class DynamicLinker(metaclass=abc.ABCMeta): def has_multi_arguments(self, args: T.List[str], env: 'Environment') -> T.Tuple[bool, bool]: raise EnvironmentException(f'Language {self.id} does not support has_multi_link_arguments.') - def get_debugfile_name(self, targetfile: str) -> str: + def get_debugfile_name(self, targetfile: str) -> T.Optional[str]: '''Name of debug file written out (see below)''' return None