mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-24 04:39:15 +00:00
Replace % string formatting with f-strings across multiple plugins (#11908)
* Replace % string formatting with f-strings across multiple plugins Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * Add changelog fragment for PR 11908 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
253ac45dd3
commit
53397c081a
14 changed files with 65 additions and 64 deletions
|
|
@ -32,8 +32,7 @@ def flatten_list(lst):
|
|||
result = []
|
||||
for sublist in lst:
|
||||
if not is_sequence(sublist):
|
||||
msg = "All arguments must be lists. %s is %s"
|
||||
raise AnsibleFilterError(msg % (sublist, type(sublist)))
|
||||
raise AnsibleFilterError(f"All arguments must be lists. {sublist} is {type(sublist)}")
|
||||
if len(sublist) > 0:
|
||||
if all(is_sequence(sub) for sub in sublist):
|
||||
for item in sublist:
|
||||
|
|
|
|||
|
|
@ -212,8 +212,9 @@ def list_mergeby(x, y, index, recursive=False, list_merge="replace"):
|
|||
for lst in (x, y):
|
||||
for elem in lst:
|
||||
if not isinstance(elem, Mapping):
|
||||
msg = "Elements of list arguments for lists_mergeby must be dictionaries. %s is %s"
|
||||
raise AnsibleFilterError(msg % (elem, type(elem)))
|
||||
raise AnsibleFilterError(
|
||||
f"Elements of list arguments for lists_mergeby must be dictionaries. {elem} is {type(elem)}"
|
||||
)
|
||||
if index in elem.keys():
|
||||
d[elem[index]].update(merge_hash(d[elem[index]], elem, recursive, list_merge))
|
||||
return sorted(d.values(), key=itemgetter(index))
|
||||
|
|
@ -236,8 +237,9 @@ def lists_mergeby(*terms, **kwargs):
|
|||
flat_list = []
|
||||
for sublist in terms[:-1]:
|
||||
if not isinstance(sublist, Sequence):
|
||||
msg = "All arguments before the argument index for community.general.lists_mergeby must be lists. %s is %s"
|
||||
raise AnsibleFilterError(msg % (sublist, type(sublist)))
|
||||
raise AnsibleFilterError(
|
||||
f"All arguments before the argument index for community.general.lists_mergeby must be lists. {sublist} is {type(sublist)}"
|
||||
)
|
||||
if len(sublist) > 0:
|
||||
if all(isinstance(lst, Sequence) for lst in sublist):
|
||||
for item in sublist:
|
||||
|
|
@ -255,8 +257,9 @@ def lists_mergeby(*terms, **kwargs):
|
|||
index = terms[-1]
|
||||
|
||||
if not isinstance(index, str):
|
||||
msg = "First argument after the lists for community.general.lists_mergeby must be string. %s is %s"
|
||||
raise AnsibleFilterError(msg % (index, type(index)))
|
||||
raise AnsibleFilterError(
|
||||
f"First argument after the lists for community.general.lists_mergeby must be string. {index} is {type(index)}"
|
||||
)
|
||||
|
||||
high_to_low_prio_list_iterator = reversed(lists)
|
||||
result = next(high_to_low_prio_list_iterator)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue