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@de33821
  • Loading branch information
tremble authored and alinabuzachis committed Oct 13, 2023
1 parent 9ae74e2 commit 0fc6001
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions plugins/modules/iam_server_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def check_duplicate_cert(new_cert):
continue
module.fail_json(
changed=False,
msg="This certificate already exists under the name {0} and dup_ok=False".format(cert_name),
msg=f"This certificate already exists under the name {cert_name} and dup_ok=False",
duplicate_cert=cert,
)

Expand Down Expand Up @@ -195,7 +195,7 @@ def create_server_certificate():
try:
client.upload_server_certificate(aws_retry=True, **params)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to update server certificate {0}".format(name))
module.fail_json_aws(e, msg=f"Failed to update server certificate {name}")

return True

Expand All @@ -217,7 +217,7 @@ def rename_server_certificate(current_cert):
cert_metadata = current_cert.get("server_certificate_metadata", {})

if not current_cert:
module.fail_json(msg="Unable to find certificate {0}".format(name))
module.fail_json(msg=f"Unable to find certificate {name}")

current_path = cert_metadata.get("path", None)
if new_path and current_path != new_path:
Expand All @@ -232,7 +232,7 @@ def rename_server_certificate(current_cert):
try:
client.update_server_certificate(aws_retry=True, ServerCertificateName=name, **changes)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to update server certificate {0}".format(name), changes=changes)
module.fail_json_aws(e, msg=f"Failed to update server certificate {name}", changes=changes)

return True

Expand All @@ -257,7 +257,7 @@ def delete_server_certificate(current_cert):
botocore.exceptions.ClientError,
botocore.exceptions.BotoCoreError,
) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg="Failed to delete server certificate {0}".format(name))
module.fail_json_aws(e, msg=f"Failed to delete server certificate {name}")

return True

Expand All @@ -276,7 +276,7 @@ def get_server_certificate(name):
botocore.exceptions.ClientError,
botocore.exceptions.BotoCoreError,
) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg="Failed to get server certificate {0}".format(name))
module.fail_json_aws(e, msg=f"Failed to get server certificate {name}")
cert = dict(camel_dict_to_snake_dict(result.get("ServerCertificate")))
return cert

Expand Down Expand Up @@ -353,7 +353,7 @@ def main():
if changed:
results["deleted_cert"] = name
else:
msg = "Certificate with the name {0} already absent".format(name)
msg = f"Certificate with the name {name} already absent"
results["msg"] = msg
else:
if new_name or new_path:
Expand Down

0 comments on commit 0fc6001

Please sign in to comment.