[PR #9324/6cd3f79e backport][stable-10] lookup plugins: use f-strings (#9367)

lookup plugins: use f-strings (#9324)

* lookup plugins: use f-strings

* add changelog frag

* manual change for few occurrences

* Update plugins/lookup/dependent.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* adjustment from review

* no f-string for you

* Update plugins/lookup/dependent.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 6cd3f79e19)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2024-12-25 16:46:55 +01:00 committed by GitHub
parent 74bd7f1471
commit a5c448d6e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 165 additions and 149 deletions

View file

@ -149,7 +149,7 @@ class LookupModule(LookupBase):
ret = []
for term in terms:
if not isinstance(term, str):
raise AnsibleError("Non-string type '{0}' passed, only 'str' types are allowed!".format(type(term)))
raise AnsibleError(f"Non-string type '{type(term)}' passed, only 'str' types are allowed!")
if not self._groups: # consider only own variables
ret.append(self._merge_vars(term, initial_value, variables))
@ -186,9 +186,9 @@ class LookupModule(LookupBase):
return False
def _merge_vars(self, search_pattern, initial_value, variables):
display.vvv("Merge variables with {0}: {1}".format(self._pattern_type, search_pattern))
display.vvv(f"Merge variables with {self._pattern_type}: {search_pattern}")
var_merge_names = sorted([key for key in variables.keys() if self._var_matches(key, search_pattern)])
display.vvv("The following variables will be merged: {0}".format(var_merge_names))
display.vvv(f"The following variables will be merged: {var_merge_names}")
prev_var_type = None
result = None
@ -226,8 +226,7 @@ class LookupModule(LookupBase):
dest[key] += value
else:
if (key in dest) and dest[key] != value:
msg = "The key '{0}' with value '{1}' will be overwritten with value '{2}' from '{3}.{0}'".format(
key, dest[key], value, ".".join(path))
msg = f"The key '{key}' with value '{dest[key]}' will be overwritten with value '{value}' from '{'.'.join(path)}.{key}'"
if self._override == "error":
raise AnsibleError(msg)