diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-06-06 12:17:59 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-06-07 16:51:47 -0400 |
commit | 998076a192b7d0f1d1411641b7f15a7dc276c4f2 (patch) | |
tree | cb0eb331f372271d35b4baace6de09840d545edb | |
parent | 3eb1da1fa2ea0b3420897afb2edd2e9c7b16eeb2 (diff) | |
download | meson-998076a192b7d0f1d1411641b7f15a7dc276c4f2.zip meson-998076a192b7d0f1d1411641b7f15a7dc276c4f2.tar.gz meson-998076a192b7d0f1d1411641b7f15a7dc276c4f2.tar.bz2 |
upgrade percent formatted strings pyupgrade did not catch
-rw-r--r-- | mesonbuild/cmake/executor.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/c.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 24 |
3 files changed, 17 insertions, 19 deletions
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index 32c660a..7b06f26 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -70,14 +70,14 @@ class CMakeExecutor: # Only search for CMake the first time and store the result in the class # definition if isinstance(CMakeExecutor.class_cmakebin[self.for_machine], NonExistingExternalProgram): - mlog.debug('CMake binary for %s is cached as not found' % self.for_machine) + mlog.debug(f'CMake binary for {self.for_machine} is cached as not found') return None, None elif CMakeExecutor.class_cmakebin[self.for_machine] is not None: - mlog.debug('CMake binary for %s is cached.' % self.for_machine) + mlog.debug(f'CMake binary for {self.for_machine} is cached.') else: assert CMakeExecutor.class_cmakebin[self.for_machine] is None - mlog.debug('CMake binary for %s is not cached' % self.for_machine) + mlog.debug(f'CMake binary for {self.for_machine} is not cached') for potential_cmakebin in find_external_program( environment, self.for_machine, 'cmake', 'CMake', environment.default_cmake, allow_default_for_cross=False): diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 15b0e29..8f62181 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -576,7 +576,7 @@ class CcrxCCompiler(CcrxCompiler, CCompiler): return ['-optimize=0'] def get_output_args(self, target: str) -> T.List[str]: - return ['-output=obj=%s' % target] + return [f'-output=obj={target}'] def get_werror_args(self) -> T.List[str]: return ['-change_message=error'] @@ -622,7 +622,7 @@ class Xc16CCompiler(Xc16Compiler, CCompiler): return ['-O0'] def get_output_args(self, target: str) -> T.List[str]: - return ['-o%s' % target] + return [f'-o{target}'] def get_werror_args(self) -> T.List[str]: return ['-change_message=error'] @@ -703,7 +703,7 @@ class C2000CCompiler(C2000Compiler, CCompiler): return ['-Ooff'] def get_output_args(self, target: str) -> T.List[str]: - return ['--output_file=%s' % target] + return [f'--output_file={target}'] def get_werror_args(self) -> T.List[str]: return ['-change_message=error'] diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 4a8cba1..6daa778 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -288,7 +288,7 @@ class CLikeCompiler(Compiler): def _sanity_check_impl(self, work_dir: str, environment: 'Environment', sname: str, code: str) -> None: mlog.debug('Sanity testing ' + self.get_display_language() + ' compiler:', ' '.join(self.exelist)) - mlog.debug('Is cross compiler: %s.' % str(self.is_cross)) + mlog.debug(f'Is cross compiler: {self.is_cross!s}.') source_name = os.path.join(work_dir, sname) binname = sname.rsplit('.', 1)[0] @@ -336,7 +336,7 @@ class CLikeCompiler(Compiler): try: pe = subprocess.Popen(cmdlist) except Exception as e: - raise mesonlib.EnvironmentException('Could not invoke sanity test executable: %s.' % str(e)) + raise mesonlib.EnvironmentException(f'Could not invoke sanity test executable: {e!s}.') pe.wait() if pe.returncode != 0: raise mesonlib.EnvironmentException(f'Executables created by {self.language} compiler {self.name_string()} are not runnable.') @@ -473,9 +473,7 @@ class CLikeCompiler(Compiler): raise compilers.CrossNoRunException('Can not run test applications in this cross environment.') with self._build_wrapper(code, env, extra_args, dependencies, mode='link', want_output=True) as p: if p.returncode != 0: - mlog.debug('Could not compile test file %s: %d\n' % ( - p.input_name, - p.returncode)) + mlog.debug(f'Could not compile test file {p.input_name}: {p.returncode}\n') return compilers.RunResult(False) if need_exe_wrapper: cmdlist = self.exe_wrapper.get_command() + [p.output_name] @@ -508,16 +506,16 @@ class CLikeCompiler(Compiler): dependencies: T.Optional[T.List['Dependency']] = None) -> int: # Try user's guess first if isinstance(guess, int): - if self._compile_int('%s == %d' % (expression, guess), prefix, env, extra_args, dependencies): + if self._compile_int(f'{expression} == {guess}', prefix, env, extra_args, dependencies): return guess # If no bounds are given, compute them in the limit of int32 maxint = 0x7fffffff minint = -0x80000000 if not isinstance(low, int) or not isinstance(high, int): - if self._compile_int('%s >= 0' % (expression), prefix, env, extra_args, dependencies): + if self._compile_int(f'{expression} >= 0', prefix, env, extra_args, dependencies): low = cur = 0 - while self._compile_int('%s > %d' % (expression, cur), prefix, env, extra_args, dependencies): + while self._compile_int(f'{expression} > {cur}', prefix, env, extra_args, dependencies): low = cur + 1 if low > maxint: raise mesonlib.EnvironmentException('Cross-compile check overflowed') @@ -527,7 +525,7 @@ class CLikeCompiler(Compiler): high = cur else: high = cur = -1 - while self._compile_int('%s < %d' % (expression, cur), prefix, env, extra_args, dependencies): + while self._compile_int(f'{expression} < {cur}', prefix, env, extra_args, dependencies): high = cur - 1 if high < minint: raise mesonlib.EnvironmentException('Cross-compile check overflowed') @@ -539,14 +537,14 @@ class CLikeCompiler(Compiler): # Sanity check limits given by user if high < low: raise mesonlib.EnvironmentException('high limit smaller than low limit') - condition = '%s <= %d && %s >= %d' % (expression, high, expression, low) + condition = f'{expression} <= {high} && {expression} >= {low}' if not self._compile_int(condition, prefix, env, extra_args, dependencies): raise mesonlib.EnvironmentException('Value out of given range') # Binary search while low != high: cur = low + int((high - low) / 2) - if self._compile_int('%s <= %d' % (expression, cur), prefix, env, extra_args, dependencies): + if self._compile_int(f'{expression} <= {cur}', prefix, env, extra_args, dependencies): high = cur else: low = cur + 1 @@ -589,7 +587,7 @@ class CLikeCompiler(Compiler): if not self.compiles(t, env, extra_args=extra_args, dependencies=dependencies)[0]: return -1 - return self.cross_compute_int('sizeof(%s)' % typename, None, None, None, prefix, env, extra_args, dependencies) + return self.cross_compute_int(f'sizeof({typename})', None, None, None, prefix, env, extra_args, dependencies) def sizeof(self, typename: str, prefix: str, env: 'Environment', *, extra_args: T.Optional[T.List[str]] = None, @@ -662,7 +660,7 @@ class CLikeCompiler(Compiler): raise mesonlib.EnvironmentException('Could not run alignment test binary.') align = int(res.stdout) if align == 0: - raise mesonlib.EnvironmentException('Could not determine alignment of %s. Sorry. You might want to file a bug.' % typename) + raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.') return align def get_define(self, dname: str, prefix: str, env: 'Environment', |