From cac4dcdb36475509c87e2b720e4a6479921c6408 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 8 May 2023 19:21:22 +0200 Subject: [PATCH] Bulk migration to Python 3.6 f-strings (#1810) 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: https://github.com/ansible-collections/community.aws/commit/de338210dc1b0bb2eecee1dc16e073163b2d1df7 --- plugins/modules/ec2_placement_group.py | 10 ++++------ plugins/modules/ec2_placement_group_info.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/modules/ec2_placement_group.py b/plugins/modules/ec2_placement_group.py index 4e1967c846d..ccdd7d54785 100644 --- a/plugins/modules/ec2_placement_group.py +++ b/plugins/modules/ec2_placement_group.py @@ -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 @@ -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)) @@ -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) @@ -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": diff --git a/plugins/modules/ec2_placement_group_info.py b/plugins/modules/ec2_placement_group_info.py index 970cd302636..75cbc72585c 100644 --- a/plugins/modules/ec2_placement_group_info.py +++ b/plugins/modules/ec2_placement_group_info.py @@ -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"]: