aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorTristan Partin <tristan@partin.io>2023-07-12 17:47:12 -0500
committerTristan Partin <tristan@partin.io>2023-07-12 18:56:06 -0500
commitd4bcf05c39e650d9651b5f2c60e7c12d59367e9c (patch)
tree1d635627d62aba0d77142583c7d1479d5e7b4d31 /mesonbuild/compilers
parent921c2370a722cbaa42bd256c699fae3185084939 (diff)
downloadmeson-d4bcf05c39e650d9651b5f2c60e7c12d59367e9c.zip
meson-d4bcf05c39e650d9651b5f2c60e7c12d59367e9c.tar.gz
meson-d4bcf05c39e650d9651b5f2c60e7c12d59367e9c.tar.bz2
Annotate naked fundamental Python types
Although mypy wasn't complaining, pyright was.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/asm.py2
-rw-r--r--mesonbuild/compilers/compilers.py2
-rw-r--r--mesonbuild/compilers/cpp.py22
-rw-r--r--mesonbuild/compilers/d.py15
-rw-r--r--mesonbuild/compilers/fortran.py6
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py2
-rw-r--r--mesonbuild/compilers/mixins/clike.py4
-rw-r--r--mesonbuild/compilers/mixins/elbrus.py4
-rw-r--r--mesonbuild/compilers/mixins/emscripten.py2
-rw-r--r--mesonbuild/compilers/mixins/gnu.py4
-rw-r--r--mesonbuild/compilers/mixins/metrowerks.py2
-rw-r--r--mesonbuild/compilers/mixins/ti.py2
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py4
13 files changed, 35 insertions, 36 deletions
diff --git a/mesonbuild/compilers/asm.py b/mesonbuild/compilers/asm.py
index ab3a638..f25473b 100644
--- a/mesonbuild/compilers/asm.py
+++ b/mesonbuild/compilers/asm.py
@@ -69,7 +69,7 @@ class NasmCompiler(Compiler):
return ['-o', outputname]
def unix_args_to_native(self, args: T.List[str]) -> T.List[str]:
- outargs = []
+ outargs: T.List[str] = []
for arg in args:
if arg == '-pthread':
continue
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 3789363..56ed2d5 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -537,7 +537,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
if not hasattr(self, 'file_suffixes'):
self.file_suffixes = lang_suffixes[self.language]
if not hasattr(self, 'can_compile_suffixes'):
- self.can_compile_suffixes = set(self.file_suffixes)
+ self.can_compile_suffixes: T.Set[str] = set(self.file_suffixes)
self.default_suffix = self.file_suffixes[0]
self.version = version
self.full_version = full_version
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index f17b0d2..cd1ed93 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -266,7 +266,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -318,7 +318,7 @@ class EmscriptenCPPCompiler(EmscriptenMixin, ClangCPPCompiler):
defines=defines, full_version=full_version)
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -362,7 +362,7 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -428,7 +428,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -539,7 +539,7 @@ class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler):
# Elbrus C++ compiler does not support RTTI, so don't check for it.
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -600,7 +600,7 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -667,7 +667,7 @@ class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
eh = options[key.evolve('eh')]
@@ -832,7 +832,7 @@ class ArmCPPCompiler(ArmCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value == 'c++11':
@@ -892,7 +892,7 @@ class TICPPCompiler(TICompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -931,7 +931,7 @@ class MetrowerksCPPCompilerARM(MetrowerksCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
std = options[OptionKey('std', machine=self.for_machine, lang=self.language)]
if std.value != 'none':
args.append('-lang')
@@ -960,7 +960,7 @@ class MetrowerksCPPCompilerEmbeddedPowerPC(MetrowerksCompiler, CPPCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
std = options[OptionKey('std', machine=self.for_machine, lang=self.language)]
if std.value != 'none':
args.append('-lang ' + std.value)
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index 358f8da..08ebb75 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -172,7 +172,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
def get_feature_args(self, kwargs: T.Dict[str, T.Any], build_to_src: str) -> T.List[str]:
# TODO: using a TypeDict here would improve this
- res = []
+ res: T.List[str] = []
# get_feature_args can be called multiple times for the same target when there is generated source
# so we have to copy the kwargs (target.d_features) dict before popping from it
kwargs = kwargs.copy()
@@ -277,7 +277,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
# The way that dmd and ldc pass rpath to gcc is different than we would
# do directly, each argument -rpath and the value to rpath, need to be
# split into two separate arguments both prefaced with the -L=.
- args = []
+ args: T.List[str] = []
(rpath_args, rpath_dirs_to_remove) = super().build_rpath_args(
env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
for r in rpath_args:
@@ -298,7 +298,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
# can understand.
# The flags might have been added by pkg-config files,
# and are therefore out of the user's control.
- dcargs = []
+ dcargs: T.List[str] = []
# whether we hit a linker argument that expect another arg
# see the comment in the "-L" section
link_expect_arg = False
@@ -421,7 +421,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
@classmethod
def translate_arg_to_windows(cls, arg: str) -> T.List[str]:
- args = []
+ args: T.List[str] = []
if arg.startswith('-Wl,'):
# Translate linker arguments here.
linkargs = arg[arg.index(',') + 1:].split(',')
@@ -447,7 +447,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
@classmethod
def _translate_arg_to_osx(cls, arg: str) -> T.List[str]:
- args = []
+ args: T.List[str] = []
if arg.startswith('-install_name'):
args.append('-L=' + arg)
return args
@@ -500,15 +500,14 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
# LDC and DMD actually do use a linker, but they proxy all of that with
# their own arguments
+ soargs: T.List[str] = []
if self.linker.id.startswith('ld.'):
- soargs = []
for arg in sargs:
a, b = arg.split(',', maxsplit=1)
soargs.append(a)
soargs.append(self.LINKER_PREFIX + b)
return soargs
elif self.linker.id.startswith('ld64'):
- soargs = []
for arg in sargs:
if not arg.startswith(self.LINKER_PREFIX):
soargs.append(self.LINKER_PREFIX + arg)
@@ -589,7 +588,7 @@ class DCompiler(Compiler):
def get_feature_args(self, kwargs: T.Dict[str, T.Any], build_to_src: str) -> T.List[str]:
# TODO: using a TypeDict here would improve this
- res = []
+ res: T.List[str] = []
# get_feature_args can be called multiple times for the same target when there is generated source
# so we have to copy the kwargs (target.d_features) dict before popping from it
kwargs = kwargs.copy()
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 06f8cb4..a80fdff 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -170,7 +170,7 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
if std.value != 'none':
@@ -311,7 +311,7 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
stds = {'legacy': 'none', 'f95': 'f95', 'f2003': 'f03', 'f2008': 'f08', 'f2018': 'f18'}
@@ -364,7 +364,7 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
return opts
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
std = options[key]
stds = {'legacy': 'none', 'f95': 'f95', 'f2003': 'f03', 'f2008': 'f08', 'f2018': 'f18'}
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index 6e503d1..71c1033 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -110,7 +110,7 @@ class CcrxCompiler(Compiler):
@classmethod
def _unix_args_to_native(cls, args: T.List[str], info: MachineInfo) -> T.List[str]:
- result = []
+ result: T.List[str] = []
for i in args:
if i.startswith('-D'):
i = '-define=' + i[2:]
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index d3e1008..978c058 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -226,7 +226,7 @@ class CLikeCompiler(Compiler):
# system directories aren't mixed, we only need to check one file for each
# directory and go by that. If we can't check the file for some reason, assume
# the compiler knows what it's doing, and accept the directory anyway.
- retval = []
+ retval: T.List[str] = []
for d in dirs:
files = [f for f in os.listdir(d) if f.endswith('.so') and os.path.isfile(os.path.join(d, f))]
# if no files, accept directory and move on
@@ -1216,7 +1216,7 @@ class CLikeCompiler(Compiler):
def _find_framework_real(self, name: str, env: 'Environment', extra_dirs: T.List[str], allow_system: bool) -> T.Optional[T.List[str]]:
code = 'int main(void) { return 0; }'
- link_args = []
+ link_args: T.List[str] = []
for d in extra_dirs:
link_args += ['-F' + d]
# We can pass -Z to disable searching in the system frameworks, but
diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py
index 872649b..ad6b7ca 100644
--- a/mesonbuild/compilers/mixins/elbrus.py
+++ b/mesonbuild/compilers/mixins/elbrus.py
@@ -74,7 +74,7 @@ class ElbrusCompiler(GnuLikeCompiler):
os_env['LC_ALL'] = 'C'
p = subprocess.Popen(self.get_exelist(ccache=False) + ['-xc', '-E', '-v', '-'], env=os_env, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stderr = p.stderr.read().decode('utf-8', errors='replace')
- includes = []
+ includes: T.List[str] = []
for line in stderr.split('\n'):
if line.lstrip().startswith('--sys_include'):
includes.append(re.sub(r'\s*\\$', '', re.sub(r'^\s*--sys_include\s*', '', line)))
@@ -91,7 +91,7 @@ class ElbrusCompiler(GnuLikeCompiler):
return 'pch'
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- args = []
+ args: T.List[str] = []
std = options[OptionKey('std', lang=self.language, machine=self.for_machine)]
if std.value != 'none':
args.append('-std=' + std.value)
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]
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index 703fb1a..7b7bc89 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -483,7 +483,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
# pathlib treats empty paths as '.', so filter those out
paths = [p for p in pathstr.split(pathsep) if p]
- result = []
+ result: T.List[str] = []
for p in paths:
# GCC returns paths like this:
# /usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/lib
@@ -590,7 +590,7 @@ class GnuCompiler(GnuLikeCompiler):
return args
def supported_warn_args(self, warn_args_by_version: T.Dict[str, T.List[str]]) -> T.List[str]:
- result = []
+ result: T.List[str] = []
for version, warn_args in warn_args_by_version.items():
if mesonlib.version_compare(self.version, '>=' + version):
result += warn_args
diff --git a/mesonbuild/compilers/mixins/metrowerks.py b/mesonbuild/compilers/mixins/metrowerks.py
index 970faeb..7aab9b5 100644
--- a/mesonbuild/compilers/mixins/metrowerks.py
+++ b/mesonbuild/compilers/mixins/metrowerks.py
@@ -278,7 +278,7 @@ class MetrowerksCompiler(Compiler):
@classmethod
def _unix_args_to_native(cls, args: T.List[str], info: MachineInfo) -> T.List[str]:
- result = []
+ result: T.List[str] = []
for i in args:
if i.startswith('-D'):
i = '-D' + i[2:]
diff --git a/mesonbuild/compilers/mixins/ti.py b/mesonbuild/compilers/mixins/ti.py
index 53688a9..6123aea 100644
--- a/mesonbuild/compilers/mixins/ti.py
+++ b/mesonbuild/compilers/mixins/ti.py
@@ -126,7 +126,7 @@ class TICompiler(Compiler):
@classmethod
def _unix_args_to_native(cls, args: T.List[str], info: MachineInfo) -> T.List[str]:
- result = []
+ result: T.List[str] = []
for i in args:
if i.startswith('-D'):
i = '--define=' + i[2:]
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index cd71558..54a95bb 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -277,7 +277,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
@classmethod
def native_args_to_unix(cls, args: T.List[str]) -> T.List[str]:
- result = []
+ result: T.List[str] = []
for arg in args:
if arg.startswith(('/LIBPATH:', '-LIBPATH:')):
result.append('-L' + arg[9:])
@@ -491,7 +491,7 @@ class ClangClCompiler(VisualStudioLikeCompiler):
def get_dependency_compile_args(self, dep: 'Dependency') -> T.List[str]:
if dep.get_include_type() == 'system':
- converted = []
+ converted: T.List[str] = []
for i in dep.get_compile_args():
if i.startswith('-isystem'):
converted += ['/clang:' + i]