Skip to content

Commit

Permalink
[7.0.0] Apply isort and flynt (#1962)
Browse files Browse the repository at this point in the history
SUMMARY

Apply isort - see also ansible-collections/amazon.aws#1771
Apply flynt - see also ansible-collections/amazon.aws#1802

ISSUE TYPE

    Feature Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION
  • Loading branch information
tremble authored Oct 17, 2023
1 parent b753fe5 commit c0117b5
Show file tree
Hide file tree
Showing 79 changed files with 272 additions and 162 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/changelog_and_linters.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---
name: changelog
name: changelog and linters

on: [workflow_call] # allow this workflow to be called from other workflows

jobs:
changelog:
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
linters:
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main
uses: ansible-network/github_actions/.github/workflows/tox.yml@main
with:
envname: ""
labelname: "lint"
4 changes: 4 additions & 0 deletions changelogs/fragments/1962-isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
minor_changes:
- community.aws collection - apply isort code formatting to ensure consistent formatting of code (https://github.com/ansible-collections/community.aws/pull/1962)
- api_gateway - use fstrings where appropriate (https://github.com/ansible-collections/amazon.aws/pull/1962).
- api_gateway_info - use fstrings where appropriate (https://github.com/ansible-collections/amazon.aws/pull/1962).
3 changes: 2 additions & 1 deletion plugins/module_utils/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.common import set_collection_info
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule

from ansible_collections.community.aws.plugins.module_utils.common import COMMUNITY_AWS_COLLECTION_NAME
from ansible_collections.community.aws.plugins.module_utils.common import COMMUNITY_AWS_COLLECTION_VERSION

Expand Down
7 changes: 3 additions & 4 deletions plugins/module_utils/networkfirewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from copy import deepcopy
import time
from copy import deepcopy

from ansible.module_utils._text import to_text
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
Expand All @@ -13,14 +13,13 @@
from ansible_collections.amazon.aws.plugins.module_utils.arn import parse_aws_arn
from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags

from ansible_collections.community.aws.plugins.module_utils.base import Boto3Mixin
from ansible_collections.community.aws.plugins.module_utils.base import BaseResourceManager
from ansible_collections.community.aws.plugins.module_utils.base import BaseWaiterFactory

from ansible_collections.community.aws.plugins.module_utils.base import Boto3Mixin
from ansible_collections.community.aws.plugins.module_utils.ec2 import BaseEc2Manager


Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from copy import deepcopy
import datetime
import functools
import time
from copy import deepcopy

try:
import botocore
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/sns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

import re
import copy
import re

try:
import botocore
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/acm_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@


import base64
from copy import deepcopy
import re # regex library
from copy import deepcopy

try:
import botocore
Expand Down
10 changes: 5 additions & 5 deletions plugins/modules/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags


def main():
Expand Down Expand Up @@ -288,7 +288,7 @@ def main():
module.exit_json(changed=False, msg="No API gateway identified with tags provided")
api_id = rest_api["id"]
elif not describe_api(client, module, api_id):
module.exit_json(changed=False, msg="API gateway id '{0}' does not exist.".format(api_id))
module.exit_json(changed=False, msg=f"API gateway id '{api_id}' does not exist.")

if module.check_mode:
module.exit_json(changed=True, msg="Delete operation skipped - running in check mode.", api_id=api_id)
Expand Down Expand Up @@ -425,7 +425,7 @@ def get_api_by_tags(client, module, name, tags):
args = "Tags"
if name:
args += " and name"
module.fail_json(msg="{0} provided do not identify a unique API gateway".format(args))
module.fail_json(msg=f"{args} provided do not identify a unique API gateway")
return result


Expand Down Expand Up @@ -500,7 +500,7 @@ def describe_api(client, module, rest_api_id):
botocore.exceptions.ClientError,
botocore.exceptions.BotoCoreError,
) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg="Trying to get Rest API '{0}'.".format(rest_api_id))
module.fail_json_aws(e, msg=f"Trying to get Rest API '{rest_api_id}'.")
return response


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/api_gateway_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _describe_rest_api(connection, module, rest_api_id):
botocore.exceptions.ClientError,
botocore.exceptions.BotoCoreError,
) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg="Trying to get Rest API '{0}'.".format(rest_api_id))
module.fail_json_aws(e, msg=f"Trying to get Rest API '{rest_api_id}'.")
return response


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/application_autoscaling_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@
except ImportError:
pass # handled by AnsibleAWSModule

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible.module_utils.common.dict_transformations import _camel_to_snake
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/batch_compute_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@
from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict

from ansible_collections.amazon.aws.plugins.module_utils.arn import validate_aws_arn
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

# ---------------------------------------------------------------------------------------------------
#
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/batch_job_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


# ---------------------------------------------------------------------------------------------------
#
# Helper Functions & classes
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/cloudformation_exports_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"""

try:
from botocore.exceptions import ClientError
from botocore.exceptions import BotoCoreError
from botocore.exceptions import ClientError
except ImportError:
pass # handled by AnsibleAWSModule

Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/cloudfront_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,9 @@
sample: abcd1234-1234-abcd-abcd-abcd12345678
"""

from collections import OrderedDict
import datetime
import re
from collections import OrderedDict

try:
import botocore
Expand All @@ -1426,8 +1426,8 @@

from ansible.module_utils._text import to_native
from ansible.module_utils._text import to_text
from ansible.module_utils.common.dict_transformations import recursive_diff
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible.module_utils.common.dict_transformations import recursive_diff
from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict

from ansible_collections.amazon.aws.plugins.module_utils.cloudfront_facts import CloudFrontFactsServiceManager
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/config_delivery_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


# this waits for an IAM role to become fully available, at the cost of
# taking a long time to fail when the IAM role/policy really is invalid
retry_unavailable_iam_on_put_delivery = AWSRetry.jittered_backoff(
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


DP_ACTIVE_STATES = ["ACTIVE", "SCHEDULED"]
DP_INACTIVE_STATES = ["INACTIVE", "PENDING", "FINISHED", "DELETING"]
DP_ACTIVATING_STATE = "ACTIVATING"
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/directconnect_confirm_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


retry_params = {"retries": 10, "delay": 5, "backoff": 1.2, "catch_extra_error_codes": ["DirectConnectClientException"]}


Expand Down
1 change: 0 additions & 1 deletion plugins/modules/directconnect_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


retry_params = {"retries": 10, "delay": 5, "backoff": 1.2, "catch_extra_error_codes": ["DirectConnectClientException"]}


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/directconnect_link_aggregation_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
returned: when I(state=present)
"""

import traceback
import time
import traceback

try:
import botocore
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/dms_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


backoff_params = dict(retries=5, delay=1, backoff=1.5)


Expand Down
1 change: 0 additions & 1 deletion plugins/modules/dms_replication_subnet_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


backoff_params = dict(retries=5, delay=1, backoff=1.5)


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_carrier_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_customer_gateway_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

Expand Down
1 change: 0 additions & 1 deletion plugins/modules/ec2_vpc_nacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


# VPC-supported IANA protocol numbers
# http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
PROTOCOL_NUMBERS = {"all": -1, "icmp": 1, "tcp": 6, "udp": 17, "ipv6-icmp": 58}
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/ec2_vpc_nacl_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


# VPC-supported IANA protocol numbers
# http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
PROTOCOL_NAMES = {"-1": "all", "1": "icmp", "6": "tcp", "17": "udp"}
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_vpc_peering_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@

from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_vpc_vgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications
from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_vpc_vpn_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ecs_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
except ImportError:
pass # Handled by AnsibleAWSModule

from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ecs_ecr.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@
from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict
from ansible.module_utils.six import string_types

from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto_exception
from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/ecs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


DEPLOYMENT_CONTROLLER_TYPE_MAP = {
"type": "str",
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/efs_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@
pass

from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


MAX_AWS_RETRIES = 10 # How many retries to perform when an API call is failing
WAIT_RETRY = 5 # how many seconds to wait between propagation status polls

Expand Down
1 change: 0 additions & 1 deletion plugins/modules/elb_classic_lb_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


MAX_AWS_RETRIES = 5
MAX_AWS_DELAY = 5

Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/elb_network_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags
from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ELBListener
from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ELBListeners
from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import NetworkLoadBalancer
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/mq_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@
pass

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule

from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule

PARAMS_MAP = {
"authentication_strategy": "AuthenticationStrategy",
Expand Down
Loading

0 comments on commit c0117b5

Please sign in to comment.