Skip to content

Commit

Permalink
Bulk migration to Python 3.6 f-strings (ansible-collections#1810)
Browse files Browse the repository at this point in the history
Bulk migration to Python 3.6 f-strings

SUMMARY
We've dropped support for Python <3.6, bulk migrate to fstrings and perform some general string cleanup
A combination of

black --preview
flynt
some manual cleanup

ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/
tests/
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@de33821
  • Loading branch information
tremble authored and GomathiselviS committed Oct 17, 2024
1 parent f1aa372 commit b0e7843
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions plugins/modules/ec2_placement_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def search_placement_group(connection, module):
try:
response = connection.describe_placement_groups(Filters=[{"Name": "group-name", "Values": [name]}])
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Couldn't find placement group named [%s]" % name)
module.fail_json_aws(e, msg=f"Couldn't find placement group named [{name}]")

if len(response["PlacementGroups"]) != 1:
return None
Expand Down Expand Up @@ -178,7 +178,7 @@ def create_placement_group(connection, module):
botocore.exceptions.ClientError,
botocore.exceptions.BotoCoreError,
) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg="Couldn't create placement group [%s]" % name)
module.fail_json_aws(e, msg=f"Couldn't create placement group [{name}]")

module.exit_json(changed=True, placement_group=get_placement_group_information(connection, name))

Expand All @@ -190,7 +190,7 @@ def delete_placement_group(connection, module):
try:
connection.delete_placement_group(GroupName=name, DryRun=module.check_mode)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Couldn't delete placement group [%s]" % name)
module.fail_json_aws(e, msg=f"Couldn't delete placement group [{name}]")

module.exit_json(changed=True)

Expand Down Expand Up @@ -220,9 +220,7 @@ def main():
else:
name = module.params.get("name")
module.fail_json(
msg=("Placement group '{}' exists, can't change strategy" + " from '{}' to '{}'").format(
name, placement_group["strategy"], strategy
)
msg=f"Placement group '{name}' exists, can't change strategy from '{placement_group['strategy']}' to '{strategy}'"
)

elif state == "absent":
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_placement_group_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_placement_groups_details(connection, module):
else:
response = connection.describe_placement_groups()
except (BotoCoreError, ClientError) as e:
module.fail_json_aws(e, msg="Couldn't find placement groups named [%s]" % names)
module.fail_json_aws(e, msg=f"Couldn't find placement groups named [{names}]")

results = []
for placement_group in response["PlacementGroups"]:
Expand Down

0 comments on commit b0e7843

Please sign in to comment.