diff options
Diffstat (limited to 'mesonbuild/interpreterbase.py')
-rw-r--r-- | mesonbuild/interpreterbase.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 376f8b0..aba9ed4 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -65,7 +65,7 @@ class ObjectHolder(T.Generic[TV_InterpreterObject]): self.subproject = subproject def __repr__(self) -> str: - return '<Holder: {!r}>'.format(self.held_object) + return f'<Holder: {self.held_object!r}>' class MesonVersionString(str): pass @@ -101,7 +101,7 @@ def _get_callee_args(wrapped_args: T.Sequence[T.Any], want_subproject: bool = Fa kwargs = None subproject = wrapped_args[1].subproject else: - raise AssertionError('Unknown args: {!r}'.format(wrapped_args)) + raise AssertionError(f'Unknown args: {wrapped_args!r}') elif n == 3: # Methods on objects (*Holder, MesonMain, etc) have 3 args: self, args, kwargs node = s.current_node @@ -134,7 +134,7 @@ def _get_callee_args(wrapped_args: T.Sequence[T.Any], want_subproject: bool = Fa if want_subproject: subproject = wrapped_args[2].subproject else: - raise AssertionError('Unknown args: {!r}'.format(wrapped_args)) + raise AssertionError(f'Unknown args: {wrapped_args!r}') # Sometimes interpreter methods are called internally with None instead of # empty list/dict args = args if args is not None else [] @@ -174,7 +174,7 @@ def builtinMethodNoKwargs(f: TV_func) -> TV_func: method_name = wrapped_args[2] kwargs = wrapped_args[4] if kwargs: - mlog.warning('Method {!r} does not take keyword arguments.'.format(method_name), + mlog.warning(f'Method {method_name!r} does not take keyword arguments.', 'This will become a hard error in the future', location=node) return f(*wrapped_args, **wrapped_kwargs) @@ -224,7 +224,7 @@ class permittedKwargs: s, node, args, kwargs, _ = _get_callee_args(wrapped_args) for k in kwargs: if k not in self.permitted: - mlog.warning('''Passed invalid keyword argument "{}".'''.format(k), location=node) + mlog.warning(f'''Passed invalid keyword argument "{k}".''', location=node) mlog.warning('This will become a hard error in the future.') return f(*wrapped_args, **wrapped_kwargs) return T.cast(TV_func, wrapped) @@ -418,7 +418,7 @@ class FeatureCheckBase(metaclass=abc.ABCMeta): def wrapped(*wrapped_args: T.Any, **wrapped_kwargs: T.Any) -> T.Any: subproject = _get_callee_args(wrapped_args, want_subproject=True)[4] if subproject is None: - raise AssertionError('{!r}'.format(wrapped_args)) + raise AssertionError(f'{wrapped_args!r}') self.use(subproject) return f(*wrapped_args, **wrapped_kwargs) return T.cast(TV_func, wrapped) @@ -444,14 +444,14 @@ class FeatureNew(FeatureCheckBase): @staticmethod def get_warning_str_prefix(tv: str) -> str: - return 'Project specifies a minimum meson_version \'{}\' but uses features which were added in newer versions:'.format(tv) + return f'Project specifies a minimum meson_version \'{tv}\' but uses features which were added in newer versions:' def log_usage_warning(self, tv: str) -> None: args = [ - 'Project targeting', "'{}'".format(tv), + 'Project targeting', f"'{tv}'", 'but tried to use feature introduced in', - "'{}':".format(self.feature_version), - '{}.'.format(self.feature_name), + f"'{self.feature_version}':", + f'{self.feature_name}.', ] if self.extra_message: args.append(self.extra_message) @@ -476,10 +476,10 @@ class FeatureDeprecated(FeatureCheckBase): def log_usage_warning(self, tv: str) -> None: args = [ - 'Project targeting', "'{}'".format(tv), + 'Project targeting', f"'{tv}'", 'but tried to use feature deprecated since', - "'{}':".format(self.feature_version), - '{}.'.format(self.feature_name), + f"'{self.feature_version}':", + f'{self.feature_name}.', ] if self.extra_message: args.append(self.extra_message) @@ -505,7 +505,7 @@ class FeatureCheckKwargsBase(metaclass=abc.ABCMeta): def wrapped(*wrapped_args: T.Any, **wrapped_kwargs: T.Any) -> T.Any: kwargs, subproject = _get_callee_args(wrapped_args, want_subproject=True)[3:5] if subproject is None: - raise AssertionError('{!r}'.format(wrapped_args)) + raise AssertionError(f'{wrapped_args!r}') for arg in self.kwargs: if arg not in kwargs: continue @@ -755,7 +755,7 @@ class InterpreterBase: if isinstance(result, Disabler): return result if not(isinstance(result, bool)): - raise InvalidCode('If clause {!r} does not evaluate to true or false.'.format(result)) + raise InvalidCode(f'If clause {result!r} does not evaluate to true or false.') if result: prev_meson_version = mesonlib.project_meson_versions[self.subproject] if self.tmp_meson_version: @@ -1067,7 +1067,7 @@ The result of this is undefined and will become a hard error in a future Meson r return Disabler() if method_name == 'extract_objects': if not isinstance(obj, ObjectHolder): - raise InvalidArguments('Invalid operation "extract_objects" on variable "{}"'.format(object_name)) + raise InvalidArguments(f'Invalid operation "extract_objects" on variable "{object_name}"') self.validate_extraction(obj.held_object) obj.current_node = node return obj.method_call(method_name, args, kwargs) @@ -1161,7 +1161,7 @@ The result of this is undefined and will become a hard error in a future Meson r try: return int(obj) except Exception: - raise InterpreterException('String {!r} cannot be converted to int'.format(obj)) + raise InterpreterException(f'String {obj!r} cannot be converted to int') elif method_name == 'join': if len(posargs) != 1: raise InterpreterException('Join() takes exactly one argument.') @@ -1206,7 +1206,7 @@ The result of this is undefined and will become a hard error in a future Meson r def arg_replace(match: T.Match[str]) -> str: idx = int(match.group(1)) if idx >= len(arg_strings): - raise InterpreterException('Format placeholder @{}@ out of range.'.format(idx)) + raise InterpreterException(f'Format placeholder @{idx}@ out of range.') return arg_strings[idx] return re.sub(r'@(\d+)@', arg_replace, templ) @@ -1283,7 +1283,7 @@ The result of this is undefined and will become a hard error in a future Meson r return self.evaluate_statement(fallback) return fallback - raise InterpreterException('Key {!r} is not in the dictionary.'.format(key)) + raise InterpreterException(f'Key {key!r} is not in the dictionary.') if method_name == 'keys': if len(posargs) != 0: @@ -1326,7 +1326,7 @@ The result of this is undefined and will become a hard error in a future Meson r raise InterpreterException('Kwargs argument must not contain a "kwargs" entry. Points for thinking meta, though. :P') for k, v in to_expand.items(): if k in kwargs: - raise InterpreterException('Entry "{}" defined both as a keyword argument and in a "kwarg" entry.'.format(k)) + raise InterpreterException(f'Entry "{k}" defined both as a keyword argument and in a "kwarg" entry.') kwargs[k] = v return kwargs |