diff options
author | Tristan Partin <tristan@partin.io> | 2023-07-12 17:36:25 -0500 |
---|---|---|
committer | Tristan Partin <tristan@partin.io> | 2023-07-12 18:56:06 -0500 |
commit | 921c2370a722cbaa42bd256c699fae3185084939 (patch) | |
tree | 8884965e8f1e1413703f271ceba046e52647d723 /mesonbuild | |
parent | 1624354f33bf0a33f0e715ba1ca391ae0154ad19 (diff) | |
download | meson-921c2370a722cbaa42bd256c699fae3185084939.zip meson-921c2370a722cbaa42bd256c699fae3185084939.tar.gz meson-921c2370a722cbaa42bd256c699fae3185084939.tar.bz2 |
Replace some type comments with annotations
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/compilers/asm.py | 11 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 135 | ||||
-rw-r--r-- | mesonbuild/compilers/d.py | 78 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/ccrx.py | 27 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clang.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 26 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/compcert.py | 31 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 42 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/intel.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/metrowerks.py | 41 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/ti.py | 25 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 26 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 10 | ||||
-rw-r--r-- | mesonbuild/environment.py | 8 | ||||
-rw-r--r-- | mesonbuild/linkers/linkers.py | 26 | ||||
-rw-r--r-- | mesonbuild/utils/universal.py | 24 |
16 files changed, 275 insertions, 251 deletions
diff --git a/mesonbuild/compilers/asm.py b/mesonbuild/compilers/asm.py index e34b4a6..ab3a638 100644 --- a/mesonbuild/compilers/asm.py +++ b/mesonbuild/compilers/asm.py @@ -11,7 +11,7 @@ if T.TYPE_CHECKING: from ..mesonlib import MachineChoice from ..envconfig import MachineInfo -nasm_optimization_args = { +nasm_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-O0'], @@ -19,7 +19,7 @@ nasm_optimization_args = { '2': ['-Ox'], '3': ['-Ox'], 's': ['-Ox'], -} # type: T.Dict[str, T.List[str]] +} class NasmCompiler(Compiler): @@ -295,7 +295,12 @@ class MetrowerksAsmCompiler(MetrowerksCompiler, Compiler): Compiler.__init__(self, ccache, exelist, version, for_machine, info, linker, full_version, is_cross) MetrowerksCompiler.__init__(self) - self.warn_args = {'0': [], '1': [], '2': [], '3': [], 'everything': []} # type: T.Dict[str, T.List[str]] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': [], + '2': [], + '3': [], + 'everything': []} self.can_compile_suffixes.add('s') def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 22865d8..3789363 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -190,68 +190,77 @@ class CompileCheckMode(enum.Enum): LINK = 'link' -cuda_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': ['-g', '-G'], - 'debugoptimized': ['-g', '-lineinfo'], - 'release': [], - 'minsize': [], - 'custom': [], - } -java_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': ['-g'], - 'debugoptimized': ['-g'], - 'release': [], - 'minsize': [], - 'custom': [], - } - -rust_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': [], - 'release': [], - 'minsize': [], - 'custom': [], - } - -d_gdc_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-finline-functions'], - 'release': ['-finline-functions'], - 'minsize': [], - 'custom': [], - } - -d_ldc_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'], - 'release': ['-enable-inlining', '-Hkeep-all-bodies'], - 'minsize': [], - 'custom': [], - } - -d_dmd_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-inline'], - 'release': ['-inline'], - 'minsize': [], - 'custom': [], - } - -mono_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-optimize+'], - 'release': ['-optimize+'], - 'minsize': [], - 'custom': [], - } - -swift_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': [], - 'release': [], - 'minsize': [], - 'custom': [], - } +cuda_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': ['-g', '-G'], + 'debugoptimized': ['-g', '-lineinfo'], + 'release': [], + 'minsize': [], + 'custom': [], +} + +java_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': ['-g'], + 'debugoptimized': ['-g'], + 'release': [], + 'minsize': [], + 'custom': [], +} + +rust_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': [], + 'release': [], + 'minsize': [], + 'custom': [], +} + +d_gdc_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-finline-functions'], + 'release': ['-finline-functions'], + 'minsize': [], + 'custom': [], +} + +d_ldc_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'], + 'release': ['-enable-inlining', '-Hkeep-all-bodies'], + 'minsize': [], + 'custom': [], +} + +d_dmd_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-inline'], + 'release': ['-inline'], + 'minsize': [], + 'custom': [], +} + +mono_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-optimize+'], + 'release': ['-optimize+'], + 'minsize': [], + 'custom': [], +} + +swift_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': [], + 'release': [], + 'minsize': [], + 'custom': [], +} gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32', '-lole32', '-loleaut32', '-luuid', '-lcomdlg32', '-ladvapi32'] @@ -1017,7 +1026,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): rm_exact = ('-headerpad_max_install_names',) rm_prefixes = ('-Wl,', '-L',) rm_next = ('-L', '-framework',) - ret = [] # T.List[str] + ret: T.List[str] = [] iargs = iter(args) for arg in iargs: # Remove this argument diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index d7edbe9..358f8da 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -50,40 +50,46 @@ if T.TYPE_CHECKING: else: CompilerMixinBase = object -d_feature_args = {'gcc': {'unittest': '-funittest', - 'debug': '-fdebug', - 'version': '-fversion', - 'import_dir': '-J' - }, - 'llvm': {'unittest': '-unittest', - 'debug': '-d-debug', - 'version': '-d-version', - 'import_dir': '-J' - }, - 'dmd': {'unittest': '-unittest', - 'debug': '-debug', - 'version': '-version', - 'import_dir': '-J' - } - } # type: T.Dict[str, T.Dict[str, str]] - -ldc_optimization_args = {'plain': [], - '0': [], - 'g': [], - '1': ['-O1'], - '2': ['-O2'], - '3': ['-O3'], - 's': ['-Oz'], - } # type: T.Dict[str, T.List[str]] - -dmd_optimization_args = {'plain': [], - '0': [], - 'g': [], - '1': ['-O'], - '2': ['-O'], - '3': ['-O'], - 's': ['-O'], - } # type: T.Dict[str, T.List[str]] +d_feature_args: T.Dict[str, T.Dict[str, str]] = { + 'gcc': { + 'unittest': '-funittest', + 'debug': '-fdebug', + 'version': '-fversion', + 'import_dir': '-J' + }, + 'llvm': { + 'unittest': '-unittest', + 'debug': '-d-debug', + 'version': '-d-version', + 'import_dir': '-J' + }, + 'dmd': { + 'unittest': '-unittest', + 'debug': '-debug', + 'version': '-version', + 'import_dir': '-J' + } +} + +ldc_optimization_args: T.Dict[str, T.List[str]] = { + 'plain': [], + '0': [], + 'g': [], + '1': ['-O1'], + '2': ['-O2'], + '3': ['-O3'], + 's': ['-Oz'], +} + +dmd_optimization_args: T.Dict[str, T.List[str]] = { + 'plain': [], + '0': [], + 'g': [], + '1': ['-O'], + '2': ['-O'], + '3': ['-O'], + 's': ['-O'], +} class DmdLikeCompilerMixin(CompilerMixinBase): @@ -102,7 +108,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase): self._dmd_has_depfile = version_compare(dmd_frontend_version, ">=2.095.0") if T.TYPE_CHECKING: - mscrt_args = {} # type: T.Dict[str, T.List[str]] + mscrt_args: T.Dict[str, T.List[str]] = {} def _get_target_arch_args(self) -> T.List[str]: ... @@ -301,7 +307,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase): ] for arg in args: # Translate OS specific arguments first. - osargs = [] # type: T.List[str] + osargs: T.List[str] = [] if info.is_windows(): osargs = cls.translate_arg_to_windows(arg) elif info.is_darwin(): diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py index 1c22214..6e503d1 100644 --- a/mesonbuild/compilers/mixins/ccrx.py +++ b/mesonbuild/compilers/mixins/ccrx.py @@ -31,35 +31,35 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -ccrx_buildtype_args = { +ccrx_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -ccrx_optimization_args = { +ccrx_optimization_args: T.Dict[str, T.List[str]] = { '0': ['-optimize=0'], 'g': ['-optimize=0'], '1': ['-optimize=1'], '2': ['-optimize=2'], '3': ['-optimize=max'], 's': ['-optimize=2', '-size'] -} # type: T.Dict[str, T.List[str]] +} -ccrx_debug_args = { +ccrx_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-debug'] -} # type: T.Dict[bool, T.List[str]] +} class CcrxCompiler(Compiler): if T.TYPE_CHECKING: is_cross = True - can_compile_suffixes = set() # type: T.Set[str] + can_compile_suffixes: T.Set[str] = set() id = 'ccrx' @@ -68,12 +68,13 @@ class CcrxCompiler(Compiler): raise EnvironmentException('ccrx supports only cross-compilation.') # Assembly self.can_compile_suffixes.add('src') - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + [], - '3': default_warn_args + [], - 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': default_warn_args, + '2': default_warn_args + [], + '3': default_warn_args + [], + 'everything': default_warn_args + []} def get_pic_args(self) -> T.List[str]: # PIC support is not enabled by default for CCRX, diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index b43b246..24f24a8 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -30,13 +30,13 @@ if T.TYPE_CHECKING: from ...environment import Environment from ...dependencies import Dependency # noqa: F401 -clang_color_args = { +clang_color_args: T.Dict[str, T.List[str]] = { 'auto': ['-fcolor-diagnostics'], 'always': ['-fcolor-diagnostics'], 'never': ['-fno-color-diagnostics'], -} # type: T.Dict[str, T.List[str]] +} -clang_optimization_args = { +clang_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Og'], @@ -44,7 +44,7 @@ clang_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Oz'], -} # type: T.Dict[str, T.List[str]] +} class ClangCompiler(GnuLikeCompiler): diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index fe39ef1..d3e1008 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -103,7 +103,7 @@ class CLikeCompilerArgs(arglist.CompilerArgs): default_dirs = self.compiler.get_default_include_dirs() if default_dirs: real_default_dirs = [self._cached_realpath(i) for i in default_dirs] - bad_idx_list = [] # type: T.List[int] + bad_idx_list: T.List[int] = [] for i, each in enumerate(new): if not each.startswith('-isystem'): continue @@ -136,11 +136,11 @@ class CLikeCompiler(Compiler): """Shared bits for the C and CPP Compilers.""" if T.TYPE_CHECKING: - warn_args = {} # type: T.Dict[str, T.List[str]] + warn_args: T.Dict[str, T.List[str]] = {} # TODO: Replace this manual cache with functools.lru_cache - find_library_cache = {} # type: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], str, LibType], T.Optional[T.List[str]]] - find_framework_cache = {} # type: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], bool], T.Optional[T.List[str]]] + find_library_cache: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], str, LibType], T.Optional[T.List[str]]] = {} + find_framework_cache: T.Dict[T.Tuple[T.Tuple[str, ...], str, T.Tuple[str, ...], bool], T.Optional[T.List[str]]] = {} internal_libs = arglist.UNIXY_COMPILER_INTERNAL_LIBS def __init__(self, exe_wrapper: T.Optional['ExternalProgram'] = None): @@ -389,8 +389,8 @@ class CLikeCompiler(Compiler): dependencies=dependencies) def _get_basic_compiler_args(self, env: 'Environment', mode: CompileCheckMode) -> T.Tuple[T.List[str], T.List[str]]: - cargs = [] # type: T.List[str] - largs = [] # type: T.List[str] + cargs: T.List[str] = [] + largs: T.List[str] = [] if mode is CompileCheckMode.LINK: # Sometimes we need to manually select the CRT to use with MSVC. # One example is when trying to do a compiler check that involves @@ -446,8 +446,8 @@ class CLikeCompiler(Compiler): # TODO: we want to ensure the front end does the listifing here dependencies = [dependencies] # Collect compiler arguments - cargs = self.compiler_args() # type: arglist.CompilerArgs - largs = [] # type: T.List[str] + cargs: arglist.CompilerArgs = self.compiler_args() + largs: T.List[str] = [] for d in dependencies: # Add compile flags needed by dependencies cargs += d.get_compile_args() @@ -805,7 +805,7 @@ class CLikeCompiler(Compiler): # # class StrProto(typing.Protocol): # def __str__(self) -> str: ... - fargs = {'prefix': prefix, 'func': funcname} # type: T.Dict[str, T.Union[str, bool, int]] + fargs: T.Dict[str, T.Union[str, bool, int]] = {'prefix': prefix, 'func': funcname} # glibc defines functions that are not available on Linux as stubs that # fail with ENOSYS (such as e.g. lchmod). In this case we want to fail @@ -1002,7 +1002,7 @@ class CLikeCompiler(Compiler): return self._symbols_have_underscore_prefix_searchbin(env) def _get_patterns(self, env: 'Environment', prefixes: T.List[str], suffixes: T.List[str], shared: bool = False) -> T.List[str]: - patterns = [] # type: T.List[str] + patterns: T.List[str] = [] for p in prefixes: for s in suffixes: patterns.append(p + '{}.' + s) @@ -1066,7 +1066,7 @@ class CLikeCompiler(Compiler): @staticmethod def _sort_shlibs_openbsd(libs: T.List[str]) -> T.List[str]: - filtered = [] # type: T.List[str] + filtered: T.List[str] = [] for lib in libs: # Validate file as a shared library of type libfoo.so.X.Y ret = lib.rsplit('.so.', maxsplit=1) @@ -1205,7 +1205,7 @@ class CLikeCompiler(Compiler): os_env = os.environ.copy() os_env['LC_ALL'] = 'C' _, _, stde = mesonlib.Popen_safe(commands, env=os_env, stdin=subprocess.PIPE) - paths = [] # T.List[str] + paths: T.List[str] = [] for line in stde.split('\n'): if '(framework directory)' not in line: continue @@ -1273,7 +1273,7 @@ class CLikeCompiler(Compiler): return self.compiles(code, env, extra_args=args, mode=mode) def _has_multi_arguments(self, args: T.List[str], env: 'Environment', code: str) -> T.Tuple[bool, bool]: - new_args = [] # type: T.List[str] + new_args: T.List[str] = [] for arg in args: # some compilers, e.g. GCC, don't warn for unsupported warning-disable # flags, so when we are testing a flag like "-Wno-forgotten-towel", also diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py index d9c21a8..ac4d5aa 100644 --- a/mesonbuild/compilers/mixins/compcert.py +++ b/mesonbuild/compilers/mixins/compcert.py @@ -30,16 +30,16 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -ccomp_buildtype_args = { +ccomp_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [''], 'debug': ['-O0', '-g'], 'debugoptimized': ['-O0', '-g'], 'release': ['-O3'], 'minsize': ['-Os'], 'custom': ['-Obranchless'], -} # type: T.Dict[str, T.List[str]] +} -ccomp_optimization_args = { +ccomp_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-O0'], @@ -47,19 +47,19 @@ ccomp_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Os'] -} # type: T.Dict[str, T.List[str]] +} -ccomp_debug_args = { +ccomp_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'] -} # type: T.Dict[bool, T.List[str]] +} # As of CompCert 20.04, these arguments should be passed to the underlying gcc linker (via -WUl,<arg>) # There are probably (many) more, but these are those used by picolibc -ccomp_args_to_wul = [ +ccomp_args_to_wul: T.List[str] = [ r"^-ffreestanding$", r"^-r$" -] # type: T.List[str] +] class CompCertCompiler(Compiler): @@ -69,12 +69,13 @@ class CompCertCompiler(Compiler): # Assembly self.can_compile_suffixes.add('s') self.can_compile_suffixes.add('sx') - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + [], - '3': default_warn_args + [], - 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': default_warn_args, + '2': default_warn_args + [], + '3': default_warn_args + [], + 'everything': default_warn_args + []} def get_always_args(self) -> T.List[str]: return [] @@ -95,7 +96,7 @@ class CompCertCompiler(Compiler): @classmethod def _unix_args_to_native(cls, args: T.List[str], info: MachineInfo) -> T.List[str]: "Always returns a copy that can be independently mutated" - patched_args = [] # type: T.List[str] + patched_args: T.List[str] = [] for arg in args: added = 0 for ptrn in ccomp_args_to_wul: diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 6517a3e..703fb1a 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -42,21 +42,21 @@ else: # XXX: prevent circular references. # FIXME: this really is a posix interface not a c-like interface -clike_debug_args = { +clike_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'], -} # type: T.Dict[bool, T.List[str]] +} -gnulike_buildtype_args = { +gnulike_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -gnu_optimization_args = { +gnu_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Og'], @@ -64,9 +64,9 @@ gnu_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Os'], -} # type: T.Dict[str, T.List[str]] +} -gnulike_instruction_set_args = { +gnulike_instruction_set_args: T.Dict[str, T.List[str]] = { 'mmx': ['-mmmx'], 'sse': ['-msse'], 'sse2': ['-msse2'], @@ -77,22 +77,22 @@ gnulike_instruction_set_args = { 'avx': ['-mavx'], 'avx2': ['-mavx2'], 'neon': ['-mfpu=neon'], -} # type: T.Dict[str, T.List[str]] +} -gnu_symbol_visibility_args = { +gnu_symbol_visibility_args: T.Dict[str, T.List[str]] = { '': [], 'default': ['-fvisibility=default'], 'internal': ['-fvisibility=internal'], 'hidden': ['-fvisibility=hidden'], 'protected': ['-fvisibility=protected'], 'inlineshidden': ['-fvisibility=hidden', '-fvisibility-inlines-hidden'], -} # type: T.Dict[str, T.List[str]] +} -gnu_color_args = { +gnu_color_args: T.Dict[str, T.List[str]] = { 'auto': ['-fdiagnostics-color=auto'], 'always': ['-fdiagnostics-color=always'], 'never': ['-fdiagnostics-color=never'], -} # type: T.Dict[str, T.List[str]] +} # Warnings collected from the GCC source and documentation. This is an # objective set of all the warnings flags that apply to general projects: the @@ -118,7 +118,7 @@ gnu_color_args = { # # Omitted warnings enabled elsewhere in meson: # -Winvalid-pch (GCC 3.4.0) -gnu_common_warning_args = { +gnu_common_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wcast-qual", "-Wconversion", @@ -213,7 +213,7 @@ gnu_common_warning_args = { "-Wopenacc-parallelism", "-Wtrivial-auto-var-init", ], -} # type: T.Dict[str, T.List[str]] +} # GCC warnings for C # Omitted non-general or legacy warnings: @@ -223,7 +223,7 @@ gnu_common_warning_args = { # -Wdeclaration-after-statement # -Wtraditional # -Wtraditional-conversion -gnu_c_warning_args = { +gnu_c_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wbad-function-cast", "-Wmissing-prototypes", @@ -240,7 +240,7 @@ gnu_c_warning_args = { "4.5.0": [ "-Wunsuffixed-float-constants", ], -} # type: T.Dict[str, T.List[str]] +} # GCC warnings for C++ # Omitted non-general or legacy warnings: @@ -250,7 +250,7 @@ gnu_c_warning_args = { # -Wctad-maybe-unsupported # -Wnamespaces # -Wtemplates -gnu_cpp_warning_args = { +gnu_cpp_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wctor-dtor-privacy", "-Weffc++", @@ -309,13 +309,13 @@ gnu_cpp_warning_args = { "-Wdeprecated-enum-float-conversion", "-Winvalid-imported-macros", ], -} # type: T.Dict[str, T.List[str]] +} # GCC warnings for Objective C and Objective C++ # Omitted non-general or legacy warnings: # -Wtraditional # -Wtraditional-conversion -gnu_objc_warning_args = { +gnu_objc_warning_args: T.Dict[str, T.List[str]] = { "0.0.0": [ "-Wselector", ], @@ -326,7 +326,7 @@ gnu_objc_warning_args = { "-Wassign-intercept", "-Wstrict-selector-match", ], -} # type: T.Dict[str, T.List[str]] +} _LANG_MAP = { 'c': 'c', @@ -345,7 +345,7 @@ def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'Imm cmd = list(compiler) + [f'-x{lang}', '-E', '-v', '-'] _, stdout, _ = mesonlib.Popen_safe(cmd, stderr=subprocess.STDOUT, env=env) parse_state = 0 - paths = [] # type: T.List[str] + paths: T.List[str] = [] for line in stdout.split('\n'): line = line.strip(' \n\r\t') if parse_state == 0: diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py index b793fa8..711e77c 100644 --- a/mesonbuild/compilers/mixins/intel.py +++ b/mesonbuild/compilers/mixins/intel.py @@ -50,14 +50,14 @@ class IntelGnuLikeCompiler(GnuLikeCompiler): minsize: -O2 """ - BUILD_ARGS = { + BUILD_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': ["-g", "-traceback"], 'debugoptimized': ["-g", "-traceback"], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } OPTIM_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], @@ -129,14 +129,14 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler): """Abstractions for ICL, the Intel compiler on Windows.""" - BUILD_ARGS = { + BUILD_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': ["/Zi", "/traceback"], 'debugoptimized': ["/Zi", "/traceback"], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } OPTIM_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], diff --git a/mesonbuild/compilers/mixins/metrowerks.py b/mesonbuild/compilers/mixins/metrowerks.py index 4390145..970faeb 100644 --- a/mesonbuild/compilers/mixins/metrowerks.py +++ b/mesonbuild/compilers/mixins/metrowerks.py @@ -30,16 +30,16 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -mwcc_buildtype_args = { +mwcc_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': ['-g'], 'debugoptimized': ['-g', '-O4'], 'release': ['-O4,p'], 'minsize': ['-Os'], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -mwccarm_instruction_set_args = { +mwccarm_instruction_set_args: T.Dict[str, T.List[str]] = { 'generic': ['-proc', 'generic'], 'v4': ['-proc', 'v4'], 'v4t': ['-proc', 'v4t'], @@ -69,9 +69,9 @@ mwccarm_instruction_set_args = { 'pxa261': ['-proc', 'pxa261'], 'pxa262': ['-proc', 'pxa262'], 'pxa263': ['-proc', 'pxa263'] -} # type: T.Dict[str, T.List[str]] +} -mwcceppc_instruction_set_args = { +mwcceppc_instruction_set_args: T.Dict[str, T.List[str]] = { 'generic': ['-proc', 'generic'], '401': ['-proc', '401'], '403': ['-proc', '403'], @@ -97,9 +97,9 @@ mwcceppc_instruction_set_args = { '8260': ['-proc', '8260'], 'e500': ['-proc', 'e500'], 'gekko': ['-proc', 'gekko'], -} # type: T.Dict[str, T.List[str]] +} -mwasmarm_instruction_set_args = { +mwasmarm_instruction_set_args: T.Dict[str, T.List[str]] = { 'arm4': ['-proc', 'arm4'], 'arm4t': ['-proc', 'arm4t'], 'arm4xm': ['-proc', 'arm4xm'], @@ -112,9 +112,9 @@ mwasmarm_instruction_set_args = { 'arm5TExP': ['-proc', 'arm5TExP'], 'arm6': ['-proc', 'arm6'], 'xscale': ['-proc', 'xscale'] -} # type: T.Dict[str, T.List[str]] +} -mwasmeppc_instruction_set_args = { +mwasmeppc_instruction_set_args: T.Dict[str, T.List[str]] = { '401': ['-proc', '401'], '403': ['-proc', '403'], '505': ['-proc', '505'], @@ -165,9 +165,9 @@ mwasmeppc_instruction_set_args = { '5674': ['-proc', '5674'], 'gekko': ['-proc', 'gekko'], 'generic': ['-proc', 'generic'], -} # type: T.Dict[str, T.List[str]] +} -mwcc_optimization_args = { +mwcc_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Op'], @@ -175,12 +175,12 @@ mwcc_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-Os'] -} # type: T.Dict[str, T.List[str]] +} -mwcc_debug_args = { +mwcc_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'] -} # type: T.Dict[bool, T.List[str]] +} class MetrowerksCompiler(Compiler): @@ -197,12 +197,13 @@ class MetrowerksCompiler(Compiler): self.base_options = { OptionKey(o) for o in ['b_pch', 'b_ndebug']} - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': ['-w', 'off'], - '1': default_warn_args, - '2': default_warn_args + ['-w', 'most'], - '3': default_warn_args + ['-w', 'all'], - 'everything': default_warn_args + ['-w', 'full']} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': ['-w', 'off'], + '1': default_warn_args, + '2': default_warn_args + ['-w', 'most'], + '3': default_warn_args + ['-w', 'all'], + 'everything': default_warn_args + ['-w', 'full']} def depfile_for_object(self, objfile: str) -> T.Optional[str]: # Earlier versions of these compilers do not support specifying diff --git a/mesonbuild/compilers/mixins/ti.py b/mesonbuild/compilers/mixins/ti.py index 950c97f..53688a9 100644 --- a/mesonbuild/compilers/mixins/ti.py +++ b/mesonbuild/compilers/mixins/ti.py @@ -31,16 +31,16 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -ti_buildtype_args = { +ti_buildtype_args: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], -} # type: T.Dict[str, T.List[str]] +} -ti_optimization_args = { +ti_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['-O0'], 'g': ['-Ooff'], @@ -48,12 +48,12 @@ ti_optimization_args = { '2': ['-O2'], '3': ['-O3'], 's': ['-O4'] -} # type: T.Dict[str, T.List[str]] +} -ti_debug_args = { +ti_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['-g'] -} # type: T.Dict[bool, T.List[str]] +} class TICompiler(Compiler): @@ -67,12 +67,13 @@ class TICompiler(Compiler): self.can_compile_suffixes.add('asm') # Assembly self.can_compile_suffixes.add('cla') # Control Law Accelerator (CLA) used in C2000 - default_warn_args = [] # type: T.List[str] - self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + [], - '3': default_warn_args + [], - 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] + default_warn_args: T.List[str] = [] + self.warn_args: T.Dict[str, T.List[str]] = { + '0': [], + '1': default_warn_args, + '2': default_warn_args + [], + '3': default_warn_args + [], + 'everything': default_warn_args + []} def get_pic_args(self) -> T.List[str]: # PIC support is not enabled by default for TI compilers, diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index cc52538..cd71558 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -37,7 +37,7 @@ else: # do). This gives up DRYer type checking, with no runtime impact Compiler = object -vs32_instruction_set_args = { +vs32_instruction_set_args: T.Dict[str, T.Optional[T.List[str]]] = { 'mmx': ['/arch:SSE'], # There does not seem to be a flag just for MMX 'sse': ['/arch:SSE'], 'sse2': ['/arch:SSE2'], @@ -47,10 +47,10 @@ vs32_instruction_set_args = { 'avx': ['/arch:AVX'], 'avx2': ['/arch:AVX2'], 'neon': None, -} # T.Dicst[str, T.Optional[T.List[str]]] +} # The 64 bit compiler defaults to /arch:avx. -vs64_instruction_set_args = { +vs64_instruction_set_args: T.Dict[str, T.Optional[T.List[str]]] = { 'mmx': ['/arch:AVX'], 'sse': ['/arch:AVX'], 'sse2': ['/arch:AVX'], @@ -61,9 +61,9 @@ vs64_instruction_set_args = { 'avx': ['/arch:AVX'], 'avx2': ['/arch:AVX2'], 'neon': None, -} # T.Dicst[str, T.Optional[T.List[str]]] +} -msvc_optimization_args = { +msvc_optimization_args: T.Dict[str, T.List[str]] = { 'plain': [], '0': ['/Od'], 'g': [], # No specific flag to optimize debugging, /Zi or /ZI will create debug information @@ -71,12 +71,12 @@ msvc_optimization_args = { '2': ['/O2'], '3': ['/O2', '/Gw'], 's': ['/O1', '/Gw'], -} # type: T.Dict[str, T.List[str]] +} -msvc_debug_args = { +msvc_debug_args: T.Dict[bool, T.List[str]] = { False: [], True: ['/Zi'] -} # type: T.Dict[bool, T.List[str]] +} class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): @@ -92,15 +92,15 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): std_warn_args = ['/W3'] std_opt_args = ['/O2'] ignore_libs = arglist.UNIXY_COMPILER_INTERNAL_LIBS + ['execinfo'] - internal_libs = [] # type: T.List[str] + internal_libs: T.List[str] = [] - crt_args = { + crt_args: T.Dict[str, T.List[str]] = { 'none': [], 'md': ['/MD'], 'mdd': ['/MDd'], 'mt': ['/MT'], 'mtd': ['/MTd'], - } # type: T.Dict[str, T.List[str]] + } # /showIncludes is needed for build dependency tracking in Ninja # See: https://ninja-build.org/manual.html#_deps @@ -109,13 +109,13 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): # It is also dropped if Visual Studio 2013 or earlier is used, since it would # not be supported in that case. always_args = ['/nologo', '/showIncludes', '/utf-8'] - warn_args = { + warn_args: T.Dict[str, T.List[str]] = { '0': [], '1': ['/W2'], '2': ['/W3'], '3': ['/W4'], 'everything': ['/Wall'], - } # type: T.Dict[str, T.List[str]] + } INVOKES_LINKER = False diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index c921d64..b6dfdbf 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -368,7 +368,7 @@ class DependencyCache: """ def __init__(self, builtins: 'KeyedOptionDictType', for_machine: MachineChoice): - self.__cache = OrderedDict() # type: T.MutableMapping[TV_DepID, DependencySubCache] + self.__cache: T.MutableMapping[TV_DepID, DependencySubCache] = OrderedDict() self.__builtins = builtins self.__pkg_conf_key = OptionKey('pkg_config_path', machine=for_machine) self.__cmake_key = OptionKey('cmake_prefix_path', machine=for_machine) @@ -482,7 +482,7 @@ class CoreData: self.version = version self.options: 'MutableKeyedOptionDictType' = {} self.cross_files = self.__load_config_files(options, scratch_dir, 'cross') - self.compilers = PerMachine(OrderedDict(), OrderedDict()) # type: PerMachine[T.Dict[str, Compiler]] + self.compilers: PerMachine[T.Dict[str, Compiler]] = PerMachine(OrderedDict(), OrderedDict()) # Set of subprojects that have already been initialized once, this is # required to be stored and reloaded with the coredata, as we don't @@ -518,9 +518,9 @@ class CoreData: if not filenames: return [] - found_invalid = [] # type: T.List[str] - missing = [] # type: T.List[str] - real = [] # type: T.List[str] + found_invalid: T.List[str] = [] + missing: T.List[str] = [] + real: T.List[str] = [] for i, f in enumerate(filenames): f = os.path.expanduser(os.path.expandvars(f)) if os.path.exists(f): diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index ff7ae3a..c5cccf3 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -488,7 +488,7 @@ class Environment: os.makedirs(self.log_dir, exist_ok=True) os.makedirs(self.info_dir, exist_ok=True) try: - self.coredata = coredata.load(self.get_build_dir()) # type: coredata.CoreData + self.coredata: coredata.CoreData = coredata.load(self.get_build_dir()) self.first_invocation = False except FileNotFoundError: self.create_new_coredata(options) @@ -521,13 +521,13 @@ class Environment: # Similar to coredata.compilers, but lower level in that there is no # meta data, only names/paths. - binaries = PerMachineDefaultable() # type: PerMachineDefaultable[BinaryTable] + binaries: PerMachineDefaultable[BinaryTable] = PerMachineDefaultable() # Misc other properties about each machine. - properties = PerMachineDefaultable() # type: PerMachineDefaultable[Properties] + properties: PerMachineDefaultable[Properties] = PerMachineDefaultable() # CMake toolchain variables - cmakevars = PerMachineDefaultable() # type: PerMachineDefaultable[CMakeVariables] + cmakevars: PerMachineDefaultable[CMakeVariables] = PerMachineDefaultable() ## Setup build machine defaults diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py index edd4085..4b52c26 100644 --- a/mesonbuild/linkers/linkers.py +++ b/mesonbuild/linkers/linkers.py @@ -122,7 +122,7 @@ class VisualStudioLikeLinker: return self.always_args.copy() def get_output_args(self, target: str) -> T.List[str]: - args = [] # type: T.List[str] + args: T.List[str] = [] if self.machine: args += ['/MACHINE:' + self.machine] args += ['/OUT:' + target] @@ -355,14 +355,14 @@ class DynamicLinker(metaclass=abc.ABCMeta): """Base class for dynamic linkers.""" - _BUILDTYPE_ARGS = { + _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } @abc.abstractproperty def id(self) -> str: @@ -387,7 +387,7 @@ class DynamicLinker(metaclass=abc.ABCMeta): self.version = version self.prefix_arg = prefix_arg self.always_args = always_args - self.machine = None # type: T.Optional[str] + self.machine: T.Optional[str] = None def __repr__(self) -> str: return '<{}: v{} `{}`>'.format(type(self).__name__, self.version, ' '.join(self.exelist)) @@ -582,16 +582,16 @@ class GnuLikeDynamicLinkerMixin: for_machine = MachineChoice.HOST def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]: ... - _BUILDTYPE_ARGS = { + _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], 'release': ['-O1'], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } - _SUBSYSTEMS = { + _SUBSYSTEMS: T.Dict[str, str] = { "native": "1", "windows": "windows", "console": "console", @@ -601,7 +601,7 @@ class GnuLikeDynamicLinkerMixin: "efi_runtime_driver": "12", "efi_rom": "13", "boot_application": "16", - } # type: T.Dict[str, str] + } def get_buildtype_args(self, buildtype: str) -> T.List[str]: # We can override these in children by just overriding the @@ -769,7 +769,7 @@ class AppleDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return [] def get_link_whole_for(self, args: T.List[str]) -> T.List[str]: - result = [] # type: T.List[str] + result: T.List[str] = [] for a in args: result.extend(self._apply_prefix('-force_load')) result.append(a) @@ -1225,7 +1225,7 @@ class VisualStudioLikeLinkerMixin: for_machine = MachineChoice.HOST def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]: ... - _BUILDTYPE_ARGS = { + _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = { 'plain': [], 'debug': [], 'debugoptimized': [], @@ -1234,7 +1234,7 @@ class VisualStudioLikeLinkerMixin: 'release': ['/OPT:REF'], 'minsize': ['/INCREMENTAL:NO', '/OPT:REF'], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } def __init__(self, exelist: T.List[str], for_machine: mesonlib.MachineChoice, prefix_arg: T.Union[str, T.List[str]], always_args: T.List[str], *, @@ -1273,7 +1273,7 @@ class VisualStudioLikeLinkerMixin: def get_link_whole_for(self, args: T.List[str]) -> T.List[str]: # Only since VS2015 args = mesonlib.listify(args) - l = [] # T.List[str] + l: T.List[str] = [] for a in args: l.extend(self._apply_prefix('/WHOLEARCHIVE:' + a)) return l @@ -1473,7 +1473,7 @@ class AIXDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str, rpath_paths: T.Tuple[str, ...], build_rpath: str, install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]: - all_paths = mesonlib.OrderedSet() # type: mesonlib.OrderedSet[str] + all_paths: mesonlib.OrderedSet[str] = mesonlib.OrderedSet() # install_rpath first, followed by other paths, and the system path last if install_rpath != '': all_paths.add(install_rpath) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index db59a60..c6a4e41 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -172,7 +172,7 @@ __all__ = [ # TODO: this is such a hack, this really should be either in coredata or in the # interpreter # {subproject: project_meson_version} -project_meson_versions = collections.defaultdict(str) # type: T.DefaultDict[str, str] +project_meson_versions: T.DefaultDict[str, str] = collections.defaultdict(str) from glob import glob @@ -514,7 +514,7 @@ class PerMachine(T.Generic[_T]): machines, we can elaborate the original and then redefault them and thus avoid repeating the elaboration explicitly. """ - unfreeze = PerMachineDefaultable() # type: PerMachineDefaultable[T.Optional[_T]] + unfreeze: PerMachineDefaultable[T.Optional[_T]] = PerMachineDefaultable() unfreeze.build = self.build unfreeze.host = self.host if unfreeze.host == unfreeze.build: @@ -543,7 +543,7 @@ class PerThreeMachine(PerMachine[_T]): machines, we can elaborate the original and then redefault them and thus avoid repeating the elaboration explicitly. """ - unfreeze = PerThreeMachineDefaultable() # type: PerThreeMachineDefaultable[T.Optional[_T]] + unfreeze: PerThreeMachineDefaultable[T.Optional[_T]] = PerThreeMachineDefaultable() unfreeze.build = self.build unfreeze.host = self.host unfreeze.target = self.target @@ -1171,7 +1171,7 @@ def join_args(args: T.Iterable[str]) -> str: def do_replacement(regex: T.Pattern[str], line: str, variable_format: Literal['meson', 'cmake', 'cmake@'], confdata: T.Union[T.Dict[str, T.Tuple[str, T.Optional[str]]], 'ConfigurationData']) -> T.Tuple[str, T.Set[str]]: - missing_variables = set() # type: T.Set[str] + missing_variables: T.Set[str] = set() if variable_format == 'cmake': start_tag = '${' backslash_tag = '\\${' @@ -1386,7 +1386,7 @@ def listify(item: T.Any, flatten: bool = True) -> T.List[T.Any]: ''' if not isinstance(item, list): return [item] - result = [] # type: T.List[T.Any] + result: T.List[T.Any] = [] for i in item: if flatten and isinstance(i, list): result += listify(i, flatten=True) @@ -1427,7 +1427,7 @@ def stringlistify(item: T.Union[T.Any, T.Sequence[T.Any]]) -> T.List[str]: def expand_arguments(args: T.Iterable[str]) -> T.Optional[T.List[str]]: - expended_args = [] # type: T.List[str] + expended_args: T.List[str] = [] for arg in args: if not arg.startswith('@'): expended_args.append(arg) @@ -1546,8 +1546,8 @@ def iter_regexin_iter(regexiter: T.Iterable[str], initer: T.Iterable[str]) -> T. def _substitute_values_check_errors(command: T.List[str], values: T.Dict[str, T.Union[str, T.List[str]]]) -> None: # Error checking - inregex = ['@INPUT([0-9]+)?@', '@PLAINNAME@', '@BASENAME@'] # type: T.List[str] - outregex = ['@OUTPUT([0-9]+)?@', '@OUTDIR@'] # type: T.List[str] + inregex: T.List[str] = ['@INPUT([0-9]+)?@', '@PLAINNAME@', '@BASENAME@'] + outregex: T.List[str] = ['@OUTPUT([0-9]+)?@', '@OUTDIR@'] if '@INPUT@' not in values: # Error out if any input-derived templates are present in the command match = iter_regexin_iter(inregex, command) @@ -1611,7 +1611,7 @@ def substitute_values(command: T.List[str], values: T.Dict[str, T.Union[str, T.L _substitute_values_check_errors(command, values) # Substitution - outcmd = [] # type: T.List[str] + outcmd: T.List[str] = [] rx_keys = [re.escape(key) for key in values if key not in ('@INPUT@', '@OUTPUT@')] value_rx = re.compile('|'.join(rx_keys)) if rx_keys else None for vv in command: @@ -1677,7 +1677,7 @@ def get_filenames_templates_dict(inputs: T.List[str], outputs: T.List[str]) -> T @OUTPUT0@, @OUTPUT1@, ... one for each output file ''' - values = {} # type: T.Dict[str, T.Union[str, T.List[str]]] + values: T.Dict[str, T.Union[str, T.List[str]]] = {} # Gather values derived from the input if inputs: # We want to substitute all the inputs. @@ -1956,7 +1956,7 @@ try: from tqdm import tqdm except ImportError: # ideally we would use a typing.Protocol here, but it's part of typing_extensions until 3.8 - ProgressBar = ProgressBarFallback # type: T.Union[T.Type[ProgressBarFallback], T.Type[ProgressBarTqdm]] + ProgressBar: T.Union[T.Type[ProgressBarFallback], T.Type[ProgressBarTqdm]] = ProgressBarFallback else: class ProgressBarTqdm(tqdm): def __init__(self, *args: T.Any, bar_type: T.Optional[str] = None, **kwargs: T.Any) -> None: @@ -2056,7 +2056,7 @@ def get_wine_shortpath(winecmd: T.List[str], wine_paths: T.List[str], def run_once(func: T.Callable[..., _T]) -> T.Callable[..., _T]: - ret = [] # type: T.List[_T] + ret: T.List[_T] = [] @wraps(func) def wrapper(*args: T.Any, **kwargs: T.Any) -> _T: |