diff --git a/.github/workflows/changelog_and_linters.yml b/.github/workflows/changelog_and_linters.yml
index b14921d3ff9..4029505d03f 100644
--- a/.github/workflows/changelog_and_linters.yml
+++ b/.github/workflows/changelog_and_linters.yml
@@ -1,5 +1,5 @@
---
-name: changelog
+name: changelog and linters
on: [workflow_call] # allow this workflow to be called from other workflows
@@ -7,4 +7,7 @@ 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"
diff --git a/changelogs/fragments/1962-isort.yml b/changelogs/fragments/1962-isort.yml
new file mode 100644
index 00000000000..65eb9792250
--- /dev/null
+++ b/changelogs/fragments/1962-isort.yml
@@ -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).
diff --git a/plugins/module_utils/modules.py b/plugins/module_utils/modules.py
index 88f645c8695..2d484aa1ae6 100644
--- a/plugins/module_utils/modules.py
+++ b/plugins/module_utils/modules.py
@@ -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
diff --git a/plugins/module_utils/networkfirewall.py b/plugins/module_utils/networkfirewall.py
index be3b82130c1..19a372514df 100644
--- a/plugins/module_utils/networkfirewall.py
+++ b/plugins/module_utils/networkfirewall.py
@@ -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
@@ -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
diff --git a/plugins/module_utils/opensearch.py b/plugins/module_utils/opensearch.py
index 173c8ba6edf..13d90bd6a78 100644
--- a/plugins/module_utils/opensearch.py
+++ b/plugins/module_utils/opensearch.py
@@ -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
diff --git a/plugins/module_utils/sns.py b/plugins/module_utils/sns.py
index f4a32636c4f..3c4e2a436be 100644
--- a/plugins/module_utils/sns.py
+++ b/plugins/module_utils/sns.py
@@ -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
diff --git a/plugins/modules/acm_certificate.py b/plugins/modules/acm_certificate.py
index 204dbecb03d..0b4f7037a71 100644
--- a/plugins/modules/acm_certificate.py
+++ b/plugins/modules/acm_certificate.py
@@ -242,8 +242,8 @@
import base64
-from copy import deepcopy
import re # regex library
+from copy import deepcopy
try:
import botocore
diff --git a/plugins/modules/api_gateway.py b/plugins/modules/api_gateway.py
index 0339bf7a329..1936f8b5ad7 100644
--- a/plugins/modules/api_gateway.py
+++ b/plugins/modules/api_gateway.py
@@ -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():
@@ -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)
@@ -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
@@ -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
diff --git a/plugins/modules/api_gateway_info.py b/plugins/modules/api_gateway_info.py
index 5c904544b9c..a6d0854b7ed 100644
--- a/plugins/modules/api_gateway_info.py
+++ b/plugins/modules/api_gateway_info.py
@@ -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
diff --git a/plugins/modules/application_autoscaling_policy.py b/plugins/modules/application_autoscaling_policy.py
index 8bbd91728a6..beb2247ac28 100644
--- a/plugins/modules/application_autoscaling_policy.py
+++ b/plugins/modules/application_autoscaling_policy.py
@@ -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
diff --git a/plugins/modules/batch_compute_environment.py b/plugins/modules/batch_compute_environment.py
index d7ee4ebc1f5..e9a17f9a086 100644
--- a/plugins/modules/batch_compute_environment.py
+++ b/plugins/modules/batch_compute_environment.py
@@ -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
# ---------------------------------------------------------------------------------------------------
#
diff --git a/plugins/modules/batch_job_definition.py b/plugins/modules/batch_job_definition.py
index 9ea5dc8cefa..fb2b1996d04 100644
--- a/plugins/modules/batch_job_definition.py
+++ b/plugins/modules/batch_job_definition.py
@@ -236,7 +236,6 @@
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
-
# ---------------------------------------------------------------------------------------------------
#
# Helper Functions & classes
diff --git a/plugins/modules/cloudformation_exports_info.py b/plugins/modules/cloudformation_exports_info.py
index cf769606d47..ff32b21241f 100644
--- a/plugins/modules/cloudformation_exports_info.py
+++ b/plugins/modules/cloudformation_exports_info.py
@@ -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
diff --git a/plugins/modules/cloudfront_distribution.py b/plugins/modules/cloudfront_distribution.py
index 37fd914dbb4..52e7440f366 100644
--- a/plugins/modules/cloudfront_distribution.py
+++ b/plugins/modules/cloudfront_distribution.py
@@ -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
@@ -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
diff --git a/plugins/modules/config_delivery_channel.py b/plugins/modules/config_delivery_channel.py
index c54fb36c05c..1c3a3acdc49 100644
--- a/plugins/modules/config_delivery_channel.py
+++ b/plugins/modules/config_delivery_channel.py
@@ -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(
diff --git a/plugins/modules/data_pipeline.py b/plugins/modules/data_pipeline.py
index 4b602708163..5a62784c6e9 100644
--- a/plugins/modules/data_pipeline.py
+++ b/plugins/modules/data_pipeline.py
@@ -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"
diff --git a/plugins/modules/directconnect_confirm_connection.py b/plugins/modules/directconnect_confirm_connection.py
index 870e459327d..1e99fd5ea03 100644
--- a/plugins/modules/directconnect_confirm_connection.py
+++ b/plugins/modules/directconnect_confirm_connection.py
@@ -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"]}
diff --git a/plugins/modules/directconnect_connection.py b/plugins/modules/directconnect_connection.py
index fd55a3b5291..40e9bc91322 100644
--- a/plugins/modules/directconnect_connection.py
+++ b/plugins/modules/directconnect_connection.py
@@ -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"]}
diff --git a/plugins/modules/directconnect_link_aggregation_group.py b/plugins/modules/directconnect_link_aggregation_group.py
index 57907c93bb9..99224fee0f2 100644
--- a/plugins/modules/directconnect_link_aggregation_group.py
+++ b/plugins/modules/directconnect_link_aggregation_group.py
@@ -161,8 +161,8 @@
returned: when I(state=present)
"""
-import traceback
import time
+import traceback
try:
import botocore
diff --git a/plugins/modules/dms_endpoint.py b/plugins/modules/dms_endpoint.py
index b417003689d..f67a1263eaf 100644
--- a/plugins/modules/dms_endpoint.py
+++ b/plugins/modules/dms_endpoint.py
@@ -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)
diff --git a/plugins/modules/dms_replication_subnet_group.py b/plugins/modules/dms_replication_subnet_group.py
index 7135aa14ea6..6f847d8e35f 100644
--- a/plugins/modules/dms_replication_subnet_group.py
+++ b/plugins/modules/dms_replication_subnet_group.py
@@ -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)
diff --git a/plugins/modules/ec2_carrier_gateway.py b/plugins/modules/ec2_carrier_gateway.py
index 6517879c0f8..e02b1a7ded5 100644
--- a/plugins/modules/ec2_carrier_gateway.py
+++ b/plugins/modules/ec2_carrier_gateway.py
@@ -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
diff --git a/plugins/modules/ec2_customer_gateway_info.py b/plugins/modules/ec2_customer_gateway_info.py
index 976d3f370d2..18c1a366a0d 100644
--- a/plugins/modules/ec2_customer_gateway_info.py
+++ b/plugins/modules/ec2_customer_gateway_info.py
@@ -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
diff --git a/plugins/modules/ec2_vpc_nacl.py b/plugins/modules/ec2_vpc_nacl.py
index 022f058d0f9..46f7086bc85 100644
--- a/plugins/modules/ec2_vpc_nacl.py
+++ b/plugins/modules/ec2_vpc_nacl.py
@@ -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}
diff --git a/plugins/modules/ec2_vpc_nacl_info.py b/plugins/modules/ec2_vpc_nacl_info.py
index 40e0398b974..d95508a894e 100644
--- a/plugins/modules/ec2_vpc_nacl_info.py
+++ b/plugins/modules/ec2_vpc_nacl_info.py
@@ -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"}
diff --git a/plugins/modules/ec2_vpc_peering_info.py b/plugins/modules/ec2_vpc_peering_info.py
index ee9fda32118..badc9f8fd80 100644
--- a/plugins/modules/ec2_vpc_peering_info.py
+++ b/plugins/modules/ec2_vpc_peering_info.py
@@ -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
diff --git a/plugins/modules/ec2_vpc_vgw.py b/plugins/modules/ec2_vpc_vgw.py
index 3ca4d8013e3..135658f7639 100644
--- a/plugins/modules/ec2_vpc_vgw.py
+++ b/plugins/modules/ec2_vpc_vgw.py
@@ -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
diff --git a/plugins/modules/ec2_vpc_vpn_info.py b/plugins/modules/ec2_vpc_vpn_info.py
index 95d8a8ca7e5..d304e456833 100644
--- a/plugins/modules/ec2_vpc_vpn_info.py
+++ b/plugins/modules/ec2_vpc_vpn_info.py
@@ -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
diff --git a/plugins/modules/ecs_cluster.py b/plugins/modules/ecs_cluster.py
index fca35331f69..c354724c9c6 100644
--- a/plugins/modules/ecs_cluster.py
+++ b/plugins/modules/ecs_cluster.py
@@ -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
diff --git a/plugins/modules/ecs_ecr.py b/plugins/modules/ecs_ecr.py
index fb812ca0a45..545b8274230 100644
--- a/plugins/modules/ecs_ecr.py
+++ b/plugins/modules/ecs_ecr.py
@@ -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
diff --git a/plugins/modules/ecs_service.py b/plugins/modules/ecs_service.py
index 8115b3b34fd..3230e2e4a5b 100644
--- a/plugins/modules/ecs_service.py
+++ b/plugins/modules/ecs_service.py
@@ -695,7 +695,6 @@
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
-
DEPLOYMENT_CONTROLLER_TYPE_MAP = {
"type": "str",
}
diff --git a/plugins/modules/efs_tag.py b/plugins/modules/efs_tag.py
index 3a4c5c8ced6..c8e5a1f1667 100644
--- a/plugins/modules/efs_tag.py
+++ b/plugins/modules/efs_tag.py
@@ -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
diff --git a/plugins/modules/elb_classic_lb_info.py b/plugins/modules/elb_classic_lb_info.py
index db3fd46ac48..8ac3b1f1c6a 100644
--- a/plugins/modules/elb_classic_lb_info.py
+++ b/plugins/modules/elb_classic_lb_info.py
@@ -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
diff --git a/plugins/modules/elb_network_lb.py b/plugins/modules/elb_network_lb.py
index 76e2454aa65..fa0da3fed24 100644
--- a/plugins/modules/elb_network_lb.py
+++ b/plugins/modules/elb_network_lb.py
@@ -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
diff --git a/plugins/modules/mq_broker.py b/plugins/modules/mq_broker.py
index 5fda006b8b0..5c73e3c9104 100644
--- a/plugins/modules/mq_broker.py
+++ b/plugins/modules/mq_broker.py
@@ -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",
diff --git a/plugins/modules/mq_broker_config.py b/plugins/modules/mq_broker_config.py
index 84f1b4dff3b..781bbb7d58f 100644
--- a/plugins/modules/mq_broker_config.py
+++ b/plugins/modules/mq_broker_config.py
@@ -93,8 +93,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
DEFAULTS = {"reboot": False}
FULL_DEBUG = False
diff --git a/plugins/modules/mq_broker_info.py b/plugins/modules/mq_broker_info.py
index c96e327cd02..e760e01795d 100644
--- a/plugins/modules/mq_broker_info.py
+++ b/plugins/modules/mq_broker_info.py
@@ -55,6 +55,7 @@
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
diff --git a/plugins/modules/mq_user.py b/plugins/modules/mq_user.py
index 898212cbcba..0daf4e5b6e6 100644
--- a/plugins/modules/mq_user.py
+++ b/plugins/modules/mq_user.py
@@ -104,8 +104,8 @@
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.botocore import is_boto3_error_code
+from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
CREATE_DEFAULTS = {
"console_access": False,
diff --git a/plugins/modules/mq_user_info.py b/plugins/modules/mq_user_info.py
index 8c63f829188..64cf92da744 100644
--- a/plugins/modules/mq_user_info.py
+++ b/plugins/modules/mq_user_info.py
@@ -86,9 +86,9 @@
# handled by AnsibleAWSModule
pass
-from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
+from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
DEFAULTS = {"max_results": 100, "skip_pending_create": False, "skip_pending_delete": False, "as_dict": True}
diff --git a/plugins/modules/opensearch.py b/plugins/modules/opensearch.py
index 0cfad807d28..1c8f0deb582 100644
--- a/plugins/modules/opensearch.py
+++ b/plugins/modules/opensearch.py
@@ -481,9 +481,9 @@
"""
-from copy import deepcopy
import datetime
import json
+from copy import deepcopy
try:
import botocore
@@ -493,15 +493,15 @@
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.policy import compare_policies
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.policy import compare_policies
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.community.aws.plugins.module_utils.opensearch import compare_domain_versions
from ansible_collections.community.aws.plugins.module_utils.opensearch import ensure_tags
-from ansible_collections.community.aws.plugins.module_utils.opensearch import get_domain_status
from ansible_collections.community.aws.plugins.module_utils.opensearch import get_domain_config
+from ansible_collections.community.aws.plugins.module_utils.opensearch import get_domain_status
from ansible_collections.community.aws.plugins.module_utils.opensearch import get_target_increment_version
from ansible_collections.community.aws.plugins.module_utils.opensearch import normalize_opensearch
from ansible_collections.community.aws.plugins.module_utils.opensearch import parse_version
diff --git a/plugins/modules/s3_lifecycle.py b/plugins/modules/s3_lifecycle.py
index 1b56cf3a141..2f48e06d404 100644
--- a/plugins/modules/s3_lifecycle.py
+++ b/plugins/modules/s3_lifecycle.py
@@ -220,9 +220,9 @@
storage_class: glacier
"""
-from copy import deepcopy
import datetime
import time
+from copy import deepcopy
try:
from dateutil import parser as date_parser
diff --git a/plugins/modules/secretsmanager_secret.py b/plugins/modules/secretsmanager_secret.py
index 1a1340df723..fb2ff8ebe96 100644
--- a/plugins/modules/secretsmanager_secret.py
+++ b/plugins/modules/secretsmanager_secret.py
@@ -212,8 +212,8 @@
version_added: 4.0.0
"""
-from traceback import format_exc
import json
+from traceback import format_exc
try:
from botocore.exceptions import BotoCoreError
@@ -225,10 +225,10 @@
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.amazon.aws.plugins.module_utils.policy import compare_policies
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.amazon.aws.plugins.module_utils.policy import compare_policies
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
diff --git a/plugins/modules/sns.py b/plugins/modules/sns.py
index 493855b76e0..62c440c1f67 100644
--- a/plugins/modules/sns.py
+++ b/plugins/modules/sns.py
@@ -160,9 +160,8 @@
except ImportError:
pass # Handled by AnsibleAWSModule
-from ansible_collections.community.aws.plugins.module_utils.sns import topic_arn_lookup
-
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
+from ansible_collections.community.aws.plugins.module_utils.sns import topic_arn_lookup
def main():
diff --git a/plugins/modules/sns_topic.py b/plugins/modules/sns_topic.py
index 22a2c82c216..03e69d8c40f 100644
--- a/plugins/modules/sns_topic.py
+++ b/plugins/modules/sns_topic.py
@@ -344,12 +344,12 @@
from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
-from ansible_collections.community.aws.plugins.module_utils.sns import list_topics
-from ansible_collections.community.aws.plugins.module_utils.sns import topic_arn_lookup
-from ansible_collections.community.aws.plugins.module_utils.sns import compare_delivery_policies
-from ansible_collections.community.aws.plugins.module_utils.sns import list_topic_subscriptions
from ansible_collections.community.aws.plugins.module_utils.sns import canonicalize_endpoint
+from ansible_collections.community.aws.plugins.module_utils.sns import compare_delivery_policies
from ansible_collections.community.aws.plugins.module_utils.sns import get_info
+from ansible_collections.community.aws.plugins.module_utils.sns import list_topic_subscriptions
+from ansible_collections.community.aws.plugins.module_utils.sns import list_topics
+from ansible_collections.community.aws.plugins.module_utils.sns import topic_arn_lookup
from ansible_collections.community.aws.plugins.module_utils.sns import update_tags
diff --git a/plugins/modules/sns_topic_info.py b/plugins/modules/sns_topic_info.py
index 51ec8372eac..8cd712804cd 100644
--- a/plugins/modules/sns_topic_info.py
+++ b/plugins/modules/sns_topic_info.py
@@ -138,10 +138,10 @@
pass # handled by AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
-from ansible_collections.community.aws.plugins.module_utils.sns import list_topics
-from ansible_collections.community.aws.plugins.module_utils.sns import get_info
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
+from ansible_collections.community.aws.plugins.module_utils.sns import get_info
+from ansible_collections.community.aws.plugins.module_utils.sns import list_topics
def main():
diff --git a/plugins/modules/waf_condition.py b/plugins/modules/waf_condition.py
index b1baae378e8..aed48130d3c 100644
--- a/plugins/modules/waf_condition.py
+++ b/plugins/modules/waf_condition.py
@@ -409,10 +409,10 @@
from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.waf import MATCH_LOOKUP
-from ansible_collections.amazon.aws.plugins.module_utils.waf import run_func_with_change_token_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import get_rule_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_regional_rules_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_rules_with_backoff
+from ansible_collections.amazon.aws.plugins.module_utils.waf import run_func_with_change_token_backoff
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
diff --git a/plugins/modules/waf_rule.py b/plugins/modules/waf_rule.py
index 28ff981623d..a744d8747d8 100644
--- a/plugins/modules/waf_rule.py
+++ b/plugins/modules/waf_rule.py
@@ -146,12 +146,12 @@
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible_collections.amazon.aws.plugins.module_utils.waf import MATCH_LOOKUP
+from ansible_collections.amazon.aws.plugins.module_utils.waf import get_web_acl_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_regional_rules_with_backoff
+from ansible_collections.amazon.aws.plugins.module_utils.waf import list_regional_web_acls_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_rules_with_backoff
-from ansible_collections.amazon.aws.plugins.module_utils.waf import run_func_with_change_token_backoff
-from ansible_collections.amazon.aws.plugins.module_utils.waf import get_web_acl_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_web_acls_with_backoff
-from ansible_collections.amazon.aws.plugins.module_utils.waf import list_regional_web_acls_with_backoff
+from ansible_collections.amazon.aws.plugins.module_utils.waf import run_func_with_change_token_backoff
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
diff --git a/plugins/modules/waf_web_acl.py b/plugins/modules/waf_web_acl.py
index dd78a2778a5..b8e4d9e6290 100644
--- a/plugins/modules/waf_web_acl.py
+++ b/plugins/modules/waf_web_acl.py
@@ -168,14 +168,14 @@
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
-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
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_regional_rules_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_regional_web_acls_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_rules_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import list_web_acls_with_backoff
from ansible_collections.amazon.aws.plugins.module_utils.waf import run_func_with_change_token_backoff
+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
def get_web_acl_by_name(client, module, name):
diff --git a/pyproject.toml b/pyproject.toml
index b78e8bd0e3c..a3810fdc1e3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -28,8 +28,16 @@ src_paths = [
"tests/integration",
]
-sections=["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "ANSIBLE_CORE", "ANSIBLE_AMAZON_AWS", "ANSIBLE_COMMUNITY_AWS", "LOCALFOLDER"]
-known_third_party=["botocore", "boto3"]
-known_ansible_core=["ansible"]
-known_ansible_amazon_aws=["ansible_collections.amazon.aws"]
-known_ansible_community_aws=["ansible_collections.community.aws"]
+# Unstable
+skip = [
+ "aws_ssm.py"
+]
+
+sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "ANSIBLE_CORE", "ANSIBLE_AMAZON_AWS", "ANSIBLE_COMMUNITY_AWS", "LOCALFOLDER"]
+known_third_party = ["botocore", "boto3"]
+known_ansible_core = ["ansible"]
+known_ansible_amazon_aws = ["ansible_collections.amazon.aws"]
+known_ansible_community_aws = ["ansible_collections.community.aws"]
+
+[tool.flynt]
+transform-joins = true
diff --git a/tests/integration/targets/connection_aws_ssm_windows/aliases b/tests/integration/targets/connection_aws_ssm_windows/aliases
index eb8e0b8914b..b321dedb67a 100644
--- a/tests/integration/targets/connection_aws_ssm_windows/aliases
+++ b/tests/integration/targets/connection_aws_ssm_windows/aliases
@@ -2,3 +2,5 @@ time=10m
cloud/aws
connection_aws_ssm
+
+unstable
diff --git a/tests/integration/targets/dynamodb_table/aliases b/tests/integration/targets/dynamodb_table/aliases
index dc5eacd6f05..17466b15335 100644
--- a/tests/integration/targets/dynamodb_table/aliases
+++ b/tests/integration/targets/dynamodb_table/aliases
@@ -1,2 +1,4 @@
cloud/aws
time=50m
+
+unstable
diff --git a/tests/integration/targets/elb_target/files/ansible_lambda_target.py b/tests/integration/targets/elb_target/files/ansible_lambda_target.py
index 2f10db49a95..d652d60977e 100644
--- a/tests/integration/targets/elb_target/files/ansible_lambda_target.py
+++ b/tests/integration/targets/elb_target/files/ansible_lambda_target.py
@@ -1,4 +1,6 @@
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import json
diff --git a/tests/integration/targets/s3_bucket_notification/files/mini_lambda.py b/tests/integration/targets/s3_bucket_notification/files/mini_lambda.py
index 1710dbafdcc..c2b19be1dc1 100644
--- a/tests/integration/targets/s3_bucket_notification/files/mini_lambda.py
+++ b/tests/integration/targets/s3_bucket_notification/files/mini_lambda.py
@@ -1,6 +1,8 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
diff --git a/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py b/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py
index 501a24d7e01..f2740554d7a 100644
--- a/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py
+++ b/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py
@@ -8,12 +8,15 @@
(but without needing the OpenSSL CLI)
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import hashlib
import sys
+
from Crypto.PublicKey import RSA
if len(sys.argv) == 0:
diff --git a/tests/integration/targets/sns_topic/files/sns_topic_lambda/sns_topic_lambda.py b/tests/integration/targets/sns_topic/files/sns_topic_lambda/sns_topic_lambda.py
index 7288616460f..99c6a8105be 100644
--- a/tests/integration/targets/sns_topic/files/sns_topic_lambda/sns_topic_lambda.py
+++ b/tests/integration/targets/sns_topic/files/sns_topic_lambda/sns_topic_lambda.py
@@ -1,6 +1,8 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py
index 27bfe24507f..3df85be4f79 100644
--- a/tests/unit/compat/builtins.py
+++ b/tests/unit/compat/builtins.py
@@ -16,7 +16,9 @@
# along with Ansible. If not, see .
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py
index e6e39994467..339a1918ce9 100644
--- a/tests/unit/mock/loader.py
+++ b/tests/unit/mock/loader.py
@@ -16,15 +16,18 @@
# along with Ansible. If not, see .
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import os
from ansible.errors import AnsibleParserError
+from ansible.module_utils._text import to_bytes
+from ansible.module_utils._text import to_text
from ansible.parsing.dataloader import DataLoader
-from ansible.module_utils._text import to_bytes, to_text
class DictDataLoader(DataLoader):
diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py
index a8369effe6e..8057e5a5849 100644
--- a/tests/unit/mock/path.py
+++ b/tests/unit/mock/path.py
@@ -1,7 +1,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from unittest.mock import MagicMock
-from ansible.utils.path import unfrackpath
+from ansible.utils.path import unfrackpath
mock_unfrackpath_noop = MagicMock(spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x)
diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py
index 957e03cc68c..0d8547f503c 100644
--- a/tests/unit/mock/procenv.py
+++ b/tests/unit/mock/procenv.py
@@ -16,14 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see .
-import sys
import json
-
-from contextlib import contextmanager
-from io import BytesIO, StringIO
+import sys
import unittest
-from ansible.module_utils.six import PY3
+from contextlib import contextmanager
+from io import BytesIO
+from io import StringIO
+
from ansible.module_utils._text import to_bytes
+from ansible.module_utils.six import PY3
@contextmanager
diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py
index 9f33ab3885f..c55228c8890 100644
--- a/tests/unit/mock/vault_helper.py
+++ b/tests/unit/mock/vault_helper.py
@@ -1,11 +1,12 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
from ansible.module_utils._text import to_bytes
-
from ansible.parsing.vault import VaultSecret
diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py
index dd3b9a5d810..8c99ef40f44 100644
--- a/tests/unit/mock/yaml_helper.py
+++ b/tests/unit/mock/yaml_helper.py
@@ -1,15 +1,18 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import io
+
import yaml
from ansible.module_utils.six import PY3
-from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.parsing.yaml.dumper import AnsibleDumper
+from ansible.parsing.yaml.loader import AnsibleLoader
class YamlTestUtils(object):
diff --git a/tests/unit/plugins/connection/test_aws_ssm.py b/tests/unit/plugins/connection/test_aws_ssm.py
index 292d7d93277..d5fcb4b1e00 100644
--- a/tests/unit/plugins/connection/test_aws_ssm.py
+++ b/tests/unit/plugins/connection/test_aws_ssm.py
@@ -1,8 +1,11 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from io import StringIO
+from unittest.mock import MagicMock
+from unittest.mock import patch
+
import pytest
-from unittest.mock import patch, MagicMock
+
from ansible.playbook.play_context import PlayContext
from ansible.plugins.loader import connection_loader
diff --git a/tests/unit/plugins/inventory/test_aws_mq.py b/tests/unit/plugins/inventory/test_aws_mq.py
index f09dd931f80..8969b4a0387 100644
--- a/tests/unit/plugins/inventory/test_aws_mq.py
+++ b/tests/unit/plugins/inventory/test_aws_mq.py
@@ -18,13 +18,14 @@
# along with Ansible. If not, see .
import copy
-import pytest
import random
import string
from unittest.mock import MagicMock
from unittest.mock import call
from unittest.mock import patch
+import pytest
+
try:
import botocore
except ImportError:
@@ -32,13 +33,13 @@
pass
from ansible.errors import AnsibleError
+
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
-from ansible_collections.community.aws.plugins.inventory.aws_mq import (
- InventoryModule,
- _find_hosts_matching_statuses,
- _get_broker_host_tags,
- _add_details_to_hosts,
-)
+
+from ansible_collections.community.aws.plugins.inventory.aws_mq import InventoryModule
+from ansible_collections.community.aws.plugins.inventory.aws_mq import _add_details_to_hosts
+from ansible_collections.community.aws.plugins.inventory.aws_mq import _find_hosts_matching_statuses
+from ansible_collections.community.aws.plugins.inventory.aws_mq import _get_broker_host_tags
if not HAS_BOTO3:
pytestmark = pytest.mark.skip("test_aws_mq.py requires the python modules 'boto3' and 'botocore'")
diff --git a/tests/unit/plugins/modules/conftest.py b/tests/unit/plugins/modules/conftest.py
index 6d45d2b5709..ba4a1adc3ec 100644
--- a/tests/unit/plugins/modules/conftest.py
+++ b/tests/unit/plugins/modules/conftest.py
@@ -6,9 +6,9 @@
import pytest
-from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
+from ansible.module_utils.six import string_types
@pytest.fixture
diff --git a/tests/unit/plugins/modules/test_acm_certificate.py b/tests/unit/plugins/modules/test_acm_certificate.py
index bb40e4413f2..608246217e7 100644
--- a/tests/unit/plugins/modules/test_acm_certificate.py
+++ b/tests/unit/plugins/modules/test_acm_certificate.py
@@ -15,15 +15,18 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see .
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
from pprint import pprint
+from ansible.module_utils._text import to_text
+
from ansible_collections.community.aws.plugins.modules.acm_certificate import chain_compare
from ansible_collections.community.aws.plugins.modules.acm_certificate import pem_chain_split
-from ansible.module_utils._text import to_text
def test_chain_compare():
diff --git a/tests/unit/plugins/modules/test_api_gateway.py b/tests/unit/plugins/modules/test_api_gateway.py
index d6db6892153..f0d9de8faf8 100644
--- a/tests/unit/plugins/modules/test_api_gateway.py
+++ b/tests/unit/plugins/modules/test_api_gateway.py
@@ -5,18 +5,21 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import sys
+
import pytest
from ansible_collections.amazon.aws.plugins.module_utils import modules as aws_modules
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
-from ansible_collections.community.aws.tests.unit.plugins.modules.utils import set_module_args
import ansible_collections.community.aws.plugins.modules.api_gateway as agw
+from ansible_collections.community.aws.tests.unit.plugins.modules.utils import set_module_args
if not HAS_BOTO3:
pytestmark = pytest.mark.skip("test_api_gateway.py requires the `boto3` and `botocore` modules")
diff --git a/tests/unit/plugins/modules/test_data_pipeline.py b/tests/unit/plugins/modules/test_data_pipeline.py
index 2d6f7500209..a2bd06ad8d9 100644
--- a/tests/unit/plugins/modules/test_data_pipeline.py
+++ b/tests/unit/plugins/modules/test_data_pipeline.py
@@ -4,13 +4,16 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import collections
-import os
import json
+import os
+
import pytest
from ansible.module_utils._text import to_text
@@ -20,14 +23,18 @@
except ImportError:
pass
+from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
+
# Magic... Incorrectly identified by pylint as unused
-# pylint: disable-next=unused-import
-from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
+# isort: off
+# pylint: disable=unused-import
-# pylint: disable-next=unused-import
+from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
-from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
+# pylint: enable=unused-import
+# isort: on
+
from ansible_collections.community.aws.plugins.modules import data_pipeline
if not HAS_BOTO3:
diff --git a/tests/unit/plugins/modules/test_directconnect_confirm_connection.py b/tests/unit/plugins/modules/test_directconnect_confirm_connection.py
index 3c7d6726be0..f65648dad19 100644
--- a/tests/unit/plugins/modules/test_directconnect_confirm_connection.py
+++ b/tests/unit/plugins/modules/test_directconnect_confirm_connection.py
@@ -1,22 +1,23 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-import pytest
from unittest.mock import call
from unittest.mock import patch
+import pytest
+
try:
from botocore.exceptions import ClientError
except ImportError:
pass
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
+
+from ansible_collections.community.aws.plugins.modules import directconnect_confirm_connection
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import AnsibleExitJson
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import AnsibleFailJson
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import ModuleTestCase
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import set_module_args
-from ansible_collections.community.aws.plugins.modules import directconnect_confirm_connection
-
if not HAS_BOTO3:
pytestmark = pytest.mark.skip(
"test_directconnect_confirm_connection.py requires the `boto3` and `botocore` modules"
diff --git a/tests/unit/plugins/modules/test_directconnect_connection.py b/tests/unit/plugins/modules/test_directconnect_connection.py
index 05a187177da..f9a62084399 100644
--- a/tests/unit/plugins/modules/test_directconnect_connection.py
+++ b/tests/unit/plugins/modules/test_directconnect_connection.py
@@ -4,7 +4,9 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
@@ -13,12 +15,14 @@
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
# Magic... Incorrectly identified by pylint as unused
-# pylint: disable-next=unused-import
+# isort: off
+# pylint: disable=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
-
-# pylint: disable-next=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
+# pylint: enable=unused-import
+# isort: on
+
from ansible_collections.community.aws.plugins.modules import directconnect_connection
if not HAS_BOTO3:
diff --git a/tests/unit/plugins/modules/test_directconnect_link_aggregation_group.py b/tests/unit/plugins/modules/test_directconnect_link_aggregation_group.py
index 6269e9fe073..134be716751 100644
--- a/tests/unit/plugins/modules/test_directconnect_link_aggregation_group.py
+++ b/tests/unit/plugins/modules/test_directconnect_link_aggregation_group.py
@@ -4,25 +4,30 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
-import pytest
-import os
import collections
+import os
-# Magic... Incorrectly identified by pylint as unused
-# pylint: disable-next=unused-import
-from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
-
-# pylint: disable-next=unused-import
-from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
+import pytest
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_conn
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info
+# Magic... Incorrectly identified by pylint as unused
+# isort: off
+# pylint: disable=unused-import
+from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
+from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
+
+# pylint: enable=unused-import
+# isort: on
+
from ansible_collections.community.aws.plugins.modules import directconnect_link_aggregation_group as lag_module
if not HAS_BOTO3:
diff --git a/tests/unit/plugins/modules/test_directconnect_virtual_interface.py b/tests/unit/plugins/modules/test_directconnect_virtual_interface.py
index 096739f0ac4..62b511bde99 100644
--- a/tests/unit/plugins/modules/test_directconnect_virtual_interface.py
+++ b/tests/unit/plugins/modules/test_directconnect_virtual_interface.py
@@ -4,7 +4,9 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
@@ -13,12 +15,14 @@
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
# Magic... Incorrectly identified by pylint as unused
-# pylint: disable-next=unused-import
+# isort: off
+# pylint: disable=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
-
-# pylint: disable-next=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
+# pylint: enable=unused-import
+# isort: on
+
from ansible_collections.community.aws.plugins.modules import directconnect_virtual_interface
if not HAS_BOTO3:
diff --git a/tests/unit/plugins/modules/test_ec2_vpc_vpn.py b/tests/unit/plugins/modules/test_ec2_vpc_vpn.py
index 06be32db6db..2b5db4226dd 100644
--- a/tests/unit/plugins/modules/test_ec2_vpc_vpn.py
+++ b/tests/unit/plugins/modules/test_ec2_vpc_vpn.py
@@ -1,24 +1,29 @@
# (c) 2017 Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import os
-import pytest
-
-# Magic... Incorrectly identified by pylint as unused
-# pylint: disable-next=unused-import
-from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
-# pylint: disable-next=unused-import
-from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
+import pytest
import ansible_collections.amazon.aws.plugins.module_utils.retries as aws_retries
-from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_conn
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict
+from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info
+
+# Magic... Incorrectly identified by pylint as unused
+# isort: off
+# pylint: disable=unused-import
+from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep
+from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
+
+# pylint: enable=unused-import
+# isort: on
from ansible_collections.community.aws.plugins.modules import ec2_vpc_vpn
diff --git a/tests/unit/plugins/modules/test_ec2_win_password.py b/tests/unit/plugins/modules/test_ec2_win_password.py
index 0579e28afc3..7f832aa7156 100644
--- a/tests/unit/plugins/modules/test_ec2_win_password.py
+++ b/tests/unit/plugins/modules/test_ec2_win_password.py
@@ -14,18 +14,20 @@
"""
import datetime
-import pytest
from unittest.mock import patch
+import pytest
+
from ansible.module_utils._text import to_bytes
from ansible.module_utils._text import to_text
from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3
+
+from ansible_collections.community.aws.plugins.modules.ec2_win_password import ec2_win_password
+from ansible_collections.community.aws.plugins.modules.ec2_win_password import setup_module_object
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import AnsibleExitJson
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import ModuleTestCase
from ansible_collections.community.aws.tests.unit.plugins.modules.utils import set_module_args
-from ansible_collections.community.aws.plugins.modules.ec2_win_password import setup_module_object
-from ansible_collections.community.aws.plugins.modules.ec2_win_password import ec2_win_password
fixture_prefix = "tests/unit/plugins/modules/fixtures/certs"
diff --git a/tests/unit/plugins/modules/test_opensearch.py b/tests/unit/plugins/modules/test_opensearch.py
index 06b50b5ca57..7dcd785c9ae 100644
--- a/tests/unit/plugins/modules/test_opensearch.py
+++ b/tests/unit/plugins/modules/test_opensearch.py
@@ -1,15 +1,16 @@
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
import functools
-from ansible_collections.community.aws.plugins.module_utils.opensearch import (
- compare_domain_versions,
- parse_version,
-)
+
+from ansible_collections.community.aws.plugins.module_utils.opensearch import compare_domain_versions
+from ansible_collections.community.aws.plugins.module_utils.opensearch import parse_version
def test_parse_version():
diff --git a/tests/unit/plugins/modules/test_redshift_cross_region_snapshots.py b/tests/unit/plugins/modules/test_redshift_cross_region_snapshots.py
index 661c58e0698..1342a8d5887 100644
--- a/tests/unit/plugins/modules/test_redshift_cross_region_snapshots.py
+++ b/tests/unit/plugins/modules/test_redshift_cross_region_snapshots.py
@@ -1,5 +1,7 @@
# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
__metaclass__ = type
diff --git a/tests/unit/plugins/modules/test_route53_wait.py b/tests/unit/plugins/modules/test_route53_wait.py
index ac9cffb8fc5..57ed705c574 100644
--- a/tests/unit/plugins/modules/test_route53_wait.py
+++ b/tests/unit/plugins/modules/test_route53_wait.py
@@ -5,10 +5,7 @@
import pytest
-from ansible_collections.community.aws.plugins.modules.route53_wait import (
- detect_task_results,
-)
-
+from ansible_collections.community.aws.plugins.modules.route53_wait import detect_task_results
_SINGLE_RESULT_SUCCESS = {
"changed": True,
diff --git a/tests/unit/plugins/modules/test_ssm_inventory_info.py b/tests/unit/plugins/modules/test_ssm_inventory_info.py
index 0437adc1f8d..518a11a3bb4 100644
--- a/tests/unit/plugins/modules/test_ssm_inventory_info.py
+++ b/tests/unit/plugins/modules/test_ssm_inventory_info.py
@@ -3,15 +3,15 @@
# 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 unittest.mock import MagicMock
+from unittest.mock import patch
+
import pytest
from botocore.exceptions import BotoCoreError
-from unittest.mock import MagicMock, patch
-from ansible_collections.community.aws.plugins.modules.ssm_inventory_info import (
- execute_module,
- get_ssm_inventory,
- SsmInventoryInfoFailure,
-)
+from ansible_collections.community.aws.plugins.modules.ssm_inventory_info import SsmInventoryInfoFailure
+from ansible_collections.community.aws.plugins.modules.ssm_inventory_info import execute_module
+from ansible_collections.community.aws.plugins.modules.ssm_inventory_info import get_ssm_inventory
def test_get_ssm_inventory():
diff --git a/tests/unit/plugins/modules/utils.py b/tests/unit/plugins/modules/utils.py
index bfa1bad2ddc..a3d9e31db39 100644
--- a/tests/unit/plugins/modules/utils.py
+++ b/tests/unit/plugins/modules/utils.py
@@ -1,9 +1,9 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
import json
-
import unittest
from unittest.mock import patch
+
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
diff --git a/tox.ini b/tox.ini
index 9b187eba7e0..e425f3a6494 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,14 @@
[tox]
-skipsdist=True
+skipsdist = True
envlist = clean,ansible{2.12,2.13}-py{38,39,310}-{with_constraints,without_constraints},linters
+# Tox4 supports labels which allow us to group the environments rather than dumping all commands into a single environment
+labels =
+ format = flynt, black, isort
+ lint = complexity-report, black-lint, isort-lint, flake8-lint, flynt-lint
+ units = ansible{2.12,2.13}-py{38,39,310}-{with_constraints,without_constraints}
+
+[common]
+format_dirs = {toxinidir}/plugins {toxinidir}/tests
[testenv]
description = Run the test-suite and generate a HTML coverage report
@@ -29,19 +37,57 @@ deps =
commands = -flake8 --select C90 --max-complexity 10 --format=html --htmldir={posargs:complexity} plugins
[testenv:black]
+depends =
+ flynt, isort
deps =
black >=23.0, <24.0
+commands =
+ black {[common]format_dirs}
+[testenv:black-lint]
+deps =
+ {[testenv:black]deps}
commands =
- black {toxinidir}/plugins {toxinidir}/tests
+ black -v --check --diff {[common]format_dirs}
+
+[testenv:isort]
+deps =
+ isort
+commands =
+ isort {[common]format_dirs}
+
+[testenv:isort-lint]
+deps =
+ {[testenv:isort]deps}
+commands =
+ isort --check-only --diff {[common]format_dirs}
+
+[testenv:flake8-lint]
+deps =
+ flake8
+commands =
+ flake8 {posargs} {[common]format_dirs}
+
+[testenv:flynt]
+deps =
+ flynt
+commands =
+ flynt {[common]format_dirs}
+
+[testenv:flynt-lint]
+deps =
+ flynt
+commands =
+ flynt --dry-run {[common]format_dirs}
[testenv:linters]
deps =
{[testenv:black]deps}
+ {[testenv:isort]deps}
flake8
-
commands =
black -v --check {toxinidir}/plugins {toxinidir}/tests
+ isort --check-only --diff {toxinidir}/plugins {toxinidir}/tests
flake8 {posargs} {toxinidir}/plugins {toxinidir}/tests
[flake8]