From 3728b228a6ce112d0f55220b1c8770a4eb1aab8c Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 1 Oct 2024 09:31:22 -0700 Subject: [PATCH] compilers: remove hasattr from `can_compile_suffixes` This is never set outside the `Compiler.__init__`, only added to. As such there's no reason to have this `hasattr` check. It's wasting time *and* confusing our static checkers. --- mesonbuild/compilers/compilers.py | 4 +--- mesonbuild/compilers/mixins/ccrx.py | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index dbe802739..3ec50c958 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -451,10 +451,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): full_version: T.Optional[str] = None, is_cross: bool = False): self.exelist = ccache + exelist self.exelist_no_ccache = exelist - # In case it's been overridden by a child class already self.file_suffixes = lang_suffixes[self.language] - if not hasattr(self, 'can_compile_suffixes'): - self.can_compile_suffixes: T.Set[str] = set(self.file_suffixes) + self.can_compile_suffixes = set(self.file_suffixes) self.default_suffix = self.file_suffixes[0] self.version = version self.full_version = full_version diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py index 63270726b..d1badaa1c 100644 --- a/mesonbuild/compilers/mixins/ccrx.py +++ b/mesonbuild/compilers/mixins/ccrx.py @@ -40,7 +40,6 @@ class CcrxCompiler(Compiler): if T.TYPE_CHECKING: is_cross = True - can_compile_suffixes: T.Set[str] = set() id = 'ccrx'