diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 1f663b523..4c61abf6a 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -1257,8 +1257,7 @@ class Backend: pdir = self.get_target_private_dir(target) i = i.replace('@PRIVATE_DIR@', pdir) else: - err_msg = f'Argument {i} is of unknown type {type(i)}' - raise RuntimeError(err_msg) + raise RuntimeError(f'Argument {i} is of unknown type {type(i)}') cmd.append(i) # Substitute the rest of the template strings values = mesonlib.get_filenames_templates_dict(inputs, outputs) @@ -1449,8 +1448,7 @@ class Backend: outdir = os.path.join(incroot, h.get_install_subdir()) for f in h.get_sources(): if not isinstance(f, File): - msg = f'Invalid header type {f!r} can\'t be installed' - raise MesonException(msg) + raise MesonException(f'Invalid header type {f!r} can\'t be installed') abspath = f.absolute_path(srcdir, builddir) i = InstallDataBase(abspath, outdir, h.get_custom_install_mode(), h.subproject) d.headers.append(i) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 33db6721a..db50f6adb 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -437,8 +437,7 @@ class NinjaBackend(backends.Backend): # 'benchmark', etc, and also for RunTargets. # https://github.com/mesonbuild/meson/issues/1644 if not to_target.startswith('meson-'): - m = f'Invalid usage of create_target_alias with {to_target!r}' - raise AssertionError(m) + raise AssertionError(f'Invalid usage of create_target_alias with {to_target!r}') from_target = to_target[len('meson-'):] elem = NinjaBuildElement(self.all_outputs, from_target, 'phony', to_target) self.add_build(elem) @@ -1390,8 +1389,7 @@ int dummy; # either in the source root, or generated with configure_file and # in the build root if not isinstance(s, File): - msg = f'All sources in target {t!r} must be of type mesonlib.File, not {s!r}' - raise InvalidArguments(msg) + raise InvalidArguments(f'All sources in target {t!r} must be of type mesonlib.File, not {s!r}') f = s.rel_to_builddir(self.build_to_src) if s.endswith(('.vala', '.gs')): srctype = vala @@ -1429,8 +1427,7 @@ int dummy; (vala_src, vapi_src, other_src) = self.split_vala_sources(target) extra_dep_files = [] if not vala_src: - msg = f'Vala library {target.name!r} has no Vala or Genie source files.' - raise InvalidArguments(msg) + raise InvalidArguments(f'Vala library {target.name!r} has no Vala or Genie source files.') valac = target.compilers['vala'] c_out_dir = self.get_target_private_dir(target) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 645ab9f9e..5fe706fd3 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -684,8 +684,7 @@ class BuildTarget(Target): 'tree. Try adding it in the list of sources.' raise InvalidArguments(msg) else: - msg = f'Bad object of type {type(s).__name__!r} in target {self.name!r}.' - raise InvalidArguments(msg) + raise InvalidArguments(f'Bad object of type {type(s).__name__!r} in target {self.name!r}.') def process_sourcelist(self, sources: T.List['SourceOutputs']) -> None: """Split sources into generated and static sources. @@ -823,8 +822,7 @@ class BuildTarget(Target): check_sources = list(self.sources) compiler = self.compilers[lang] if not self.can_compile_remove_sources(compiler, check_sources): - m = f'No {lang} sources found in target {self.name!r}' - raise InvalidArguments(m) + raise InvalidArguments(f'No {lang} sources found in target {self.name!r}') if check_sources: m = '{0} targets can only contain {0} files:\n'.format(lang.capitalize()) m += '\n'.join([repr(c) for c in check_sources]) @@ -1445,8 +1443,7 @@ You probably should put it in link_with instead.''') # Pretty hard to fix because the return value is passed everywhere return linker, stdlib_args - m = f'Could not get a dynamic linker for build target {self.name!r}' - raise AssertionError(m) + raise AssertionError(f'Could not get a dynamic linker for build target {self.name!r}') def uses_rust(self) -> bool: """Is this target a rust target.""" diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index cf3f9929a..4a8cba185 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -711,16 +711,14 @@ class CLikeCompiler(Compiler): }}''' res = self.run(code, env, extra_args=extra_args, dependencies=dependencies) if not res.compiled: - m = f'Could not get return value of {fname}()' - raise mesonlib.EnvironmentException(m) + raise mesonlib.EnvironmentException(f'Could not get return value of {fname}()') if rtype == 'string': return res.stdout elif rtype == 'int': try: return int(res.stdout.strip()) except ValueError: - m = f'Return value of {fname}() is not an int' - raise mesonlib.EnvironmentException(m) + raise mesonlib.EnvironmentException(f'Return value of {fname}() is not an int') assert False, 'Unreachable' @staticmethod @@ -923,11 +921,9 @@ class CLikeCompiler(Compiler): n = 'symbols_have_underscore_prefix' with self._build_wrapper(code, env, extra_args=args, mode='compile', want_output=True, temp_dir=env.scratch_dir) as p: if p.returncode != 0: - m = f'BUG: Unable to compile {n!r} check: {p.stdout}' - raise RuntimeError(m) + raise RuntimeError(f'BUG: Unable to compile {n!r} check: {p.stdout}') if not os.path.isfile(p.output_name): - m = f'BUG: Can\'t find compiled test code for {n!r} check' - raise RuntimeError(m) + raise RuntimeError(f'BUG: Can\'t find compiled test code for {n!r} check') with open(p.output_name, 'rb') as o: for line in o: # Check if the underscore form of the symbol is somewhere