From 680cfc8292e391400f023fb6de74b3aa52367309 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Thu, 10 Nov 2022 08:34:20 +0100 Subject: [PATCH] Mass remove Python 2.x compatibility code (#1257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mass remove Python 2.x compatibility code Depends-On: #1259 SUMMARY We dropped support for Python < 3.6 in release 2.0, and ansible-test now respects this and doesn't complain about the missing compatibility code, so drop the extra code ISSUE TYPE Feature Pull Request COMPONENT NAME plugins/ tests/unit/ ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis Reviewed-by: Gonéri Le Bouder --- changelogs/fragments/1257-python2-compat.yml | 2 + plugins/action/s3_object.py | 4 +- plugins/callback/aws_resource_actions.py | 6 +- plugins/doc_fragments/aws.py | 5 +- plugins/doc_fragments/aws_credentials.py | 6 +- plugins/doc_fragments/aws_region.py | 6 +- plugins/doc_fragments/boto3.py | 6 +- plugins/doc_fragments/common.py | 7 +- plugins/doc_fragments/ec2.py | 6 +- plugins/doc_fragments/region.py | 6 +- plugins/doc_fragments/tags.py | 6 +- plugins/inventory/aws_ec2.py | 3 - plugins/inventory/aws_rds.py | 3 - plugins/lookup/aws_account_attribute.py | 4 +- plugins/lookup/aws_service_ip_ranges.py | 2 - plugins/lookup/secretsmanager_secret.py | 5 +- plugins/lookup/ssm_parameter.py | 5 +- plugins/module_utils/acm.py | 5 +- plugins/module_utils/arn.py | 3 - plugins/module_utils/batch.py | 3 - plugins/module_utils/botocore.py | 3 - plugins/module_utils/cloud.py | 3 - plugins/module_utils/cloudfront_facts.py | 5 +- plugins/module_utils/core.py | 3 - plugins/module_utils/direct_connect.py | 3 - plugins/module_utils/ec2.py | 3 - plugins/module_utils/elb_utils.py | 3 - plugins/module_utils/elbv2.py | 17 +-- plugins/module_utils/exceptions.py | 3 - plugins/module_utils/iam.py | 3 - plugins/module_utils/modules.py | 6 +- plugins/module_utils/policy.py | 3 - plugins/module_utils/rds.py | 3 - plugins/module_utils/retries.py | 5 +- plugins/module_utils/route53.py | 3 - plugins/module_utils/s3.py | 3 - plugins/module_utils/tagging.py | 3 - plugins/module_utils/tower.py | 3 - plugins/module_utils/transformation.py | 3 - plugins/module_utils/urls.py | 3 - plugins/module_utils/version.py | 6 - plugins/module_utils/waf.py | 3 - plugins/module_utils/waiters.py | 3 - plugins/modules/autoscaling_group.py | 4 - plugins/modules/autoscaling_group_info.py | 4 - plugins/modules/aws_az_info.py | 4 - plugins/modules/aws_caller_info.py | 4 - plugins/modules/cloudformation.py | 5 - plugins/modules/cloudformation_info.py | 4 - plugins/modules/cloudtrail.py | 4 - plugins/modules/cloudtrail_info.py | 4 - plugins/modules/cloudwatch_metric_alarm.py | 4 - .../modules/cloudwatch_metric_alarm_info.py | 4 - plugins/modules/cloudwatchevent_rule.py | 8 +- plugins/modules/cloudwatchlogs_log_group.py | 5 - .../modules/cloudwatchlogs_log_group_info.py | 5 - .../cloudwatchlogs_log_group_metric_filter.py | 3 - plugins/modules/ec2_ami.py | 4 - plugins/modules/ec2_ami_info.py | 4 - plugins/modules/ec2_eip.py | 5 - plugins/modules/ec2_eip_info.py | 4 - plugins/modules/ec2_eni.py | 4 - plugins/modules/ec2_eni_info.py | 4 - plugins/modules/ec2_instance.py | 4 - plugins/modules/ec2_instance_info.py | 4 - plugins/modules/ec2_key.py | 4 - plugins/modules/ec2_metadata_facts.py | 6 +- plugins/modules/ec2_security_group.py | 6 +- plugins/modules/ec2_security_group_info.py | 4 - plugins/modules/ec2_snapshot.py | 4 - plugins/modules/ec2_snapshot_info.py | 4 - plugins/modules/ec2_spot_instance.py | 4 - plugins/modules/ec2_spot_instance_info.py | 4 - plugins/modules/ec2_tag.py | 4 - plugins/modules/ec2_tag_info.py | 4 - plugins/modules/ec2_vol.py | 4 - plugins/modules/ec2_vol_info.py | 4 - plugins/modules/ec2_vpc_dhcp_option.py | 4 - plugins/modules/ec2_vpc_dhcp_option_info.py | 4 - plugins/modules/ec2_vpc_endpoint.py | 4 - plugins/modules/ec2_vpc_endpoint_info.py | 4 - .../modules/ec2_vpc_endpoint_service_info.py | 4 - plugins/modules/ec2_vpc_igw.py | 6 +- plugins/modules/ec2_vpc_igw_info.py | 4 - plugins/modules/ec2_vpc_nat_gateway.py | 4 - plugins/modules/ec2_vpc_nat_gateway_info.py | 4 - plugins/modules/ec2_vpc_net.py | 4 - plugins/modules/ec2_vpc_net_info.py | 4 - plugins/modules/ec2_vpc_route_table.py | 4 - plugins/modules/ec2_vpc_route_table_info.py | 4 - plugins/modules/ec2_vpc_subnet.py | 4 - plugins/modules/ec2_vpc_subnet_info.py | 4 - plugins/modules/elb_application_lb.py | 4 - plugins/modules/elb_application_lb_info.py | 3 - plugins/modules/elb_classic_lb.py | 5 +- plugins/modules/iam_policy.py | 4 - plugins/modules/iam_policy_info.py | 3 - plugins/modules/iam_user.py | 4 - plugins/modules/iam_user_info.py | 4 - plugins/modules/kms_key.py | 4 - plugins/modules/kms_key_info.py | 4 - plugins/modules/lambda.py | 4 - plugins/modules/lambda_alias.py | 4 - plugins/modules/lambda_event.py | 4 - plugins/modules/lambda_execute.py | 4 - plugins/modules/lambda_info.py | 4 - plugins/modules/lambda_layer.py | 4 - plugins/modules/lambda_layer_info.py | 4 - plugins/modules/lambda_policy.py | 4 - plugins/modules/rds_cluster.py | 4 - plugins/modules/rds_cluster_info.py | 4 - plugins/modules/rds_cluster_snapshot.py | 4 - plugins/modules/rds_instance.py | 4 - plugins/modules/rds_instance_info.py | 4 - plugins/modules/rds_instance_snapshot.py | 4 - plugins/modules/rds_option_group.py | 4 - plugins/modules/rds_option_group_info.py | 4 - plugins/modules/rds_param_group.py | 4 - plugins/modules/rds_snapshot_info.py | 4 - plugins/modules/rds_subnet_group.py | 6 - plugins/modules/route53.py | 6 - plugins/modules/route53_health_check.py | 4 - plugins/modules/route53_info.py | 4 - plugins/modules/route53_zone.py | 3 - plugins/modules/s3_bucket.py | 4 - plugins/modules/s3_object.py | 5 - plugins/modules/s3_object_info.py | 4 - plugins/plugin_utils/base.py | 5 +- plugins/plugin_utils/lookup.py | 3 - tests/unit/{compat => }/__init__.py | 0 tests/unit/compat/builtins.py | 33 ----- tests/unit/compat/mock.py | 122 ----------------- tests/unit/compat/unittest.py | 38 ------ tests/unit/mock/loader.py | 116 ---------------- tests/unit/mock/path.py | 8 -- tests/unit/mock/procenv.py | 90 ------------- tests/unit/mock/vault_helper.py | 39 ------ tests/unit/mock/yaml_helper.py | 124 ------------------ tests/unit/module_utils/__init__.py | 0 tests/unit/module_utils/arn/__init__.py | 0 .../module_utils/arn/test_is_outpost_arn.py | 3 - .../module_utils/arn/test_parse_aws_arn.py | 3 - tests/unit/module_utils/botocore/__init__.py | 0 .../module_utils/botocore/test_aws_region.py | 3 - .../module_utils/botocore/test_boto3_conn.py | 3 - .../botocore/test_connection_info.py | 3 - .../botocore/test_is_boto3_error_code.py | 5 +- .../botocore/test_is_boto3_error_message.py | 5 +- .../botocore/test_normalize_boto3_result.py | 3 - .../botocore/test_sdk_versions.py | 3 - tests/unit/module_utils/cloud/__init__.py | 0 .../cloud/test_backoff_iterator.py | 3 - .../module_utils/cloud/test_cloud_retry.py | 5 +- .../cloud/test_decorator_generation.py | 7 +- .../module_utils/cloud/test_retries_found.py | 3 - .../module_utils/cloud/test_retry_func.py | 7 +- tests/unit/module_utils/conftest.py | 3 - tests/unit/module_utils/elbv2/__init__.py | 0 tests/unit/module_utils/elbv2/test_prune.py | 3 - .../unit/module_utils/exceptions/__init__.py | 0 .../exceptions/test_exceptions.py | 3 - tests/unit/module_utils/modules/__init__.py | 0 .../modules/ansible_aws_module/__init__.py | 0 .../ansible_aws_module/test_fail_json_aws.py | 5 +- .../test_minimal_versions.py | 5 +- .../ansible_aws_module/test_passthrough.py | 3 - .../test_require_at_least.py | 5 +- tests/unit/module_utils/policy/__init__.py | 0 .../module_utils/policy/test_canonicalize.py | 5 +- .../policy/test_compare_policies.py | 5 +- tests/unit/module_utils/policy/test_py3cmp.py | 3 - .../policy/test_simple_hashable_policy.py | 3 - .../policy/test_sort_json_policy_dict.py | 3 - tests/unit/module_utils/retries/__init__.py | 0 .../module_utils/retries/test_awsretry.py | 5 +- .../retries/test_botocore_exception_maybe.py | 3 - .../retries/test_retry_wrapper.py | 3 - tests/unit/module_utils/test_elbv2.py | 6 +- tests/unit/module_utils/test_iam.py | 8 +- tests/unit/module_utils/test_rds.py | 8 +- tests/unit/module_utils/test_s3.py | 5 +- tests/unit/module_utils/test_tagging.py | 5 +- tests/unit/module_utils/test_tower.py | 5 - .../module_utils/transformation/__init__.py | 0 .../test_ansible_dict_to_boto3_filter_list.py | 6 +- .../transformation/test_map_complex_type.py | 5 +- .../test_scrub_none_parameters.py | 3 - tests/unit/plugin_utils/__init__.py | 0 tests/unit/plugin_utils/base/__init__.py | 0 tests/unit/plugin_utils/base/test_plugin.py | 3 - tests/unit/plugin_utils/botocore/__init__.py | 0 .../botocore/test_boto3_conn_plugin.py | 3 - .../botocore/test_get_aws_region.py | 3 - .../botocore/test_get_connection_info.py | 3 - tests/unit/plugin_utils/lookup/__init__.py | 0 .../plugin_utils/lookup/test_lookup_base.py | 3 - tests/unit/plugins/__init__.py | 0 tests/unit/plugins/inventory/__init__.py | 0 tests/unit/plugins/inventory/test_aws_ec2.py | 4 - tests/unit/plugins/modules/__init__.py | 0 tests/unit/plugins/modules/conftest.py | 3 - .../unit/plugins/modules/ec2_eip/__init__.py | 0 .../plugins/modules/ec2_instance/__init__.py | 0 .../test_build_run_instance_spec.py | 5 +- .../ec2_instance/test_determine_iam_role.py | 7 +- .../modules/ec2_security_group/__init__.py | 0 .../test_get_target_from_rule.py | 3 - .../ec2_security_group/test_validate_ip.py | 3 - .../ec2_security_group/test_validate_rule.py | 3 - .../unit/plugins/modules/fixtures/__init__.py | 0 .../modules/fixtures/certs/__init__.py | 0 .../plugins/modules/test_cloudformation.py | 6 +- .../modules/test_ec2_security_group.py | 4 - .../modules/test_ec2_vpc_dhcp_option.py | 6 +- .../unit/plugins/modules/test_lambda_layer.py | 3 - .../plugins/modules/test_lambda_layer_info.py | 3 - tests/unit/plugins/modules/utils.py | 7 +- tests/unit/utils/__init__.py | 0 218 files changed, 64 insertions(+), 1288 deletions(-) create mode 100644 changelogs/fragments/1257-python2-compat.yml rename tests/unit/{compat => }/__init__.py (100%) delete mode 100644 tests/unit/compat/builtins.py delete mode 100644 tests/unit/compat/mock.py delete mode 100644 tests/unit/compat/unittest.py delete mode 100644 tests/unit/mock/loader.py delete mode 100644 tests/unit/mock/path.py delete mode 100644 tests/unit/mock/procenv.py delete mode 100644 tests/unit/mock/vault_helper.py delete mode 100644 tests/unit/mock/yaml_helper.py create mode 100644 tests/unit/module_utils/__init__.py create mode 100644 tests/unit/module_utils/arn/__init__.py create mode 100644 tests/unit/module_utils/botocore/__init__.py create mode 100644 tests/unit/module_utils/cloud/__init__.py create mode 100644 tests/unit/module_utils/elbv2/__init__.py create mode 100644 tests/unit/module_utils/exceptions/__init__.py create mode 100644 tests/unit/module_utils/modules/__init__.py create mode 100644 tests/unit/module_utils/modules/ansible_aws_module/__init__.py create mode 100644 tests/unit/module_utils/policy/__init__.py create mode 100644 tests/unit/module_utils/retries/__init__.py create mode 100644 tests/unit/module_utils/transformation/__init__.py create mode 100644 tests/unit/plugin_utils/__init__.py create mode 100644 tests/unit/plugin_utils/base/__init__.py create mode 100644 tests/unit/plugin_utils/botocore/__init__.py create mode 100644 tests/unit/plugin_utils/lookup/__init__.py create mode 100644 tests/unit/plugins/__init__.py create mode 100644 tests/unit/plugins/inventory/__init__.py create mode 100644 tests/unit/plugins/modules/__init__.py create mode 100644 tests/unit/plugins/modules/ec2_eip/__init__.py create mode 100644 tests/unit/plugins/modules/ec2_instance/__init__.py create mode 100644 tests/unit/plugins/modules/ec2_security_group/__init__.py create mode 100644 tests/unit/plugins/modules/fixtures/__init__.py create mode 100644 tests/unit/plugins/modules/fixtures/certs/__init__.py create mode 100644 tests/unit/utils/__init__.py diff --git a/changelogs/fragments/1257-python2-compat.yml b/changelogs/fragments/1257-python2-compat.yml new file mode 100644 index 00000000000..89e0f4a1681 --- /dev/null +++ b/changelogs/fragments/1257-python2-compat.yml @@ -0,0 +1,2 @@ +breaking_changes: +- amazon.aws - compatibility code for Python < 3.6 has been removed (https://github.com/ansible-collections/amazon.aws/pull/1257). diff --git a/plugins/action/s3_object.py b/plugins/action/s3_object.py index a78dd0bed15..b23ef8c291e 100644 --- a/plugins/action/s3_object.py +++ b/plugins/action/s3_object.py @@ -15,8 +15,6 @@ # # 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) -__metaclass__ = type import os @@ -41,7 +39,7 @@ def run(self, tmp=None, task_vars=None): if task_vars is None: task_vars = dict() - result = super(ActionModule, self).run(tmp, task_vars) + result = super().run(tmp, task_vars) del tmp # tmp no longer has any effect source = self._task.args.get('src', None) diff --git a/plugins/callback/aws_resource_actions.py b/plugins/callback/aws_resource_actions.py index 551a866a376..7fecddeefb7 100644 --- a/plugins/callback/aws_resource_actions.py +++ b/plugins/callback/aws_resource_actions.py @@ -1,10 +1,6 @@ # (C) 2018 Ansible Project # 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) -__metaclass__ = type - DOCUMENTATION = ''' name: aws_resource_actions type: aggregate @@ -47,7 +43,7 @@ class CallbackModule(CallbackBase): def __init__(self): self.aws_resource_actions = [] - super(CallbackModule, self).__init__() + super().__init__() def extend_aws_resource_actions(self, result): if result.get('resource_actions'): diff --git a/plugins/doc_fragments/aws.py b/plugins/doc_fragments/aws.py index b250b8708ac..5403dca98d1 100644 --- a/plugins/doc_fragments/aws.py +++ b/plugins/doc_fragments/aws.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from .common import ModuleDocFragment as CommonFragment # @@ -15,6 +12,6 @@ # -class ModuleDocFragment(object): +class ModuleDocFragment: def __init__(self): self.DOCUMENTATION = CommonFragment.MODULES diff --git a/plugins/doc_fragments/aws_credentials.py b/plugins/doc_fragments/aws_credentials.py index f5b396260b2..fcac8014865 100644 --- a/plugins/doc_fragments/aws_credentials.py +++ b/plugins/doc_fragments/aws_credentials.py @@ -1,18 +1,14 @@ # -*- coding: utf-8 -*- - # Copyright: (c) 2017, 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) -__metaclass__ = type - # # The amazon.aws.aws_credentials docs fragment has been deprecated, # please migrate to amazon.aws.common.plugins. # -class ModuleDocFragment(object): +class ModuleDocFragment: # Plugin options for AWS credentials DOCUMENTATION = r""" diff --git a/plugins/doc_fragments/aws_region.py b/plugins/doc_fragments/aws_region.py index a56228931a8..f078438cee6 100644 --- a/plugins/doc_fragments/aws_region.py +++ b/plugins/doc_fragments/aws_region.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- - # (c) 2022 Red Hat Inc. # # This file is part of Ansible # 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) -__metaclass__ = type - from .region import ModuleDocFragment as RegionFragment # @@ -16,6 +12,6 @@ # -class ModuleDocFragment(object): +class ModuleDocFragment: def __init__(self): self.DOCUMENTATION = RegionFragment.PLUGINS diff --git a/plugins/doc_fragments/boto3.py b/plugins/doc_fragments/boto3.py index 5d053d7222e..0cc30f6853e 100644 --- a/plugins/doc_fragments/boto3.py +++ b/plugins/doc_fragments/boto3.py @@ -1,15 +1,11 @@ # -*- coding: utf-8 -*- - # Copyright: (c) 2022, 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) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils import botocore as botocore_utils -class ModuleDocFragment(object): +class ModuleDocFragment: # Modules and Plugins can (currently) use the same fragment def __init__(self): diff --git a/plugins/doc_fragments/common.py b/plugins/doc_fragments/common.py index 8ea2adcc422..b2ce235332f 100644 --- a/plugins/doc_fragments/common.py +++ b/plugins/doc_fragments/common.py @@ -1,18 +1,13 @@ # -*- coding: utf-8 -*- - # Copyright: (c) 2014, Will Thames # 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) -__metaclass__ = type - - MODULES = r""" options: {} """ -class ModuleDocFragment(object): +class ModuleDocFragment: # Common configuration for all AWS services # Note: If you're updating MODULES, PLUGINS probably needs updating too. diff --git a/plugins/doc_fragments/ec2.py b/plugins/doc_fragments/ec2.py index 7af5ba026f5..4d904e6703e 100644 --- a/plugins/doc_fragments/ec2.py +++ b/plugins/doc_fragments/ec2.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- - # (c) 2022 Red Hat Inc. # # This file is part of Ansible # 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) -__metaclass__ = type - from .region import ModuleDocFragment as RegionFragment # @@ -16,6 +12,6 @@ # -class ModuleDocFragment(object): +class ModuleDocFragment: def __init__(self): self.DOCUMENTATION = RegionFragment.MODULES diff --git a/plugins/doc_fragments/region.py b/plugins/doc_fragments/region.py index f57b1b3811a..b5c94a0f028 100644 --- a/plugins/doc_fragments/region.py +++ b/plugins/doc_fragments/region.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- - # Copyright: (c) 2015, Ansible, 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) -__metaclass__ = type - -class ModuleDocFragment(object): +class ModuleDocFragment: # Common configuration for all AWS services # Note: If you're updating MODULES, PLUGINS probably needs updating too. diff --git a/plugins/doc_fragments/tags.py b/plugins/doc_fragments/tags.py index 71f4da36b66..ecb8f82a9f0 100644 --- a/plugins/doc_fragments/tags.py +++ b/plugins/doc_fragments/tags.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- - # Copyright: (c) 2022, 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) -__metaclass__ = type - -class ModuleDocFragment(object): +class ModuleDocFragment: # Standard Tagging related parameters DOCUMENTATION = r""" diff --git a/plugins/inventory/aws_ec2.py b/plugins/inventory/aws_ec2.py index 6452f003f98..67299ef305b 100644 --- a/plugins/inventory/aws_ec2.py +++ b/plugins/inventory/aws_ec2.py @@ -1,9 +1,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - DOCUMENTATION = ''' name: aws_ec2 short_description: EC2 inventory source diff --git a/plugins/inventory/aws_rds.py b/plugins/inventory/aws_rds.py index e03464168f7..ed950d2be56 100644 --- a/plugins/inventory/aws_rds.py +++ b/plugins/inventory/aws_rds.py @@ -1,9 +1,6 @@ # Copyright (c) 2018 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) -__metaclass__ = type - DOCUMENTATION = ''' name: aws_rds short_description: RDS instance inventory source diff --git a/plugins/lookup/aws_account_attribute.py b/plugins/lookup/aws_account_attribute.py index 499a7f589d0..97a716ddb52 100644 --- a/plugins/lookup/aws_account_attribute.py +++ b/plugins/lookup/aws_account_attribute.py @@ -1,7 +1,5 @@ # (c) 2017 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) -__metaclass__ = type DOCUMENTATION = r""" name: aws_account_attribute @@ -67,7 +65,7 @@ def _describe_account_attributes(client, **params): class LookupModule(AWSLookupBase): def run(self, terms, variables, **kwargs): - super(LookupModule, self).run(terms, variables, **kwargs) + super().run(terms, variables, **kwargs) client = self.client('ec2', AWSRetry.jittered_backoff()) diff --git a/plugins/lookup/aws_service_ip_ranges.py b/plugins/lookup/aws_service_ip_ranges.py index 938fcd20cf3..38f2a997bda 100644 --- a/plugins/lookup/aws_service_ip_ranges.py +++ b/plugins/lookup/aws_service_ip_ranges.py @@ -1,8 +1,6 @@ # (c) 2016 James Turner # (c) 2017 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) -__metaclass__ = type DOCUMENTATION = ''' name: aws_service_ip_ranges diff --git a/plugins/lookup/secretsmanager_secret.py b/plugins/lookup/secretsmanager_secret.py index f7266e8994f..6e4afcbd290 100644 --- a/plugins/lookup/secretsmanager_secret.py +++ b/plugins/lookup/secretsmanager_secret.py @@ -1,9 +1,6 @@ # Copyright: (c) 2018, Aaron Smith # 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) -__metaclass__ = type - DOCUMENTATION = r""" name: secretsmanager_secret author: @@ -147,7 +144,7 @@ def run(self, terms, variables, **kwargs): :returns: A list of parameter values or a list of dictionaries if bypath=True. ''' - super(LookupModule, self).run(terms, variables, **kwargs) + super().run(terms, variables, **kwargs) on_missing = self.get_option('on_missing') on_denied = self.get_option('on_denied') diff --git a/plugins/lookup/ssm_parameter.py b/plugins/lookup/ssm_parameter.py index f04c126f060..68b1758dcf5 100644 --- a/plugins/lookup/ssm_parameter.py +++ b/plugins/lookup/ssm_parameter.py @@ -4,9 +4,6 @@ # (c) 2017 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) -__metaclass__ = type - DOCUMENTATION = r""" name: ssm_parameter author: @@ -154,7 +151,7 @@ def run(self, terms, variables, **kwargs): :returns: A list of parameter values or a list of dictionaries if bypath=True. ''' - super(LookupModule, self).run(terms, variables, **kwargs) + super().run(terms, variables, **kwargs) on_missing = self.get_option('on_missing') on_denied = self.get_option('on_denied') diff --git a/plugins/module_utils/acm.py b/plugins/module_utils/acm.py index 81c65507eea..924e840ce4c 100644 --- a/plugins/module_utils/acm.py +++ b/plugins/module_utils/acm.py @@ -24,9 +24,6 @@ # - acm_certificate # - acm_certificate_info -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - """ Common Amazon Certificate Manager facts shared between modules """ @@ -45,7 +42,7 @@ from .ec2 import boto3_tag_list_to_ansible_dict -class ACMServiceManager(object): +class ACMServiceManager: """Handles ACM Facts Services""" def __init__(self, module): diff --git a/plugins/module_utils/arn.py b/plugins/module_utils/arn.py index ac8dfc9e023..b182986de70 100644 --- a/plugins/module_utils/arn.py +++ b/plugins/module_utils/arn.py @@ -16,9 +16,6 @@ # 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) -__metaclass__ = type - import re diff --git a/plugins/module_utils/batch.py b/plugins/module_utils/batch.py index c2721451943..c05811ad432 100644 --- a/plugins/module_utils/batch.py +++ b/plugins/module_utils/batch.py @@ -29,9 +29,6 @@ This module adds shared support for Batch modules. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict diff --git a/plugins/module_utils/botocore.py b/plugins/module_utils/botocore.py index 85f99d79f2a..d9c418ff025 100644 --- a/plugins/module_utils/botocore.py +++ b/plugins/module_utils/botocore.py @@ -31,9 +31,6 @@ connections. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import json import os import traceback diff --git a/plugins/module_utils/cloud.py b/plugins/module_utils/cloud.py index 38b98c848f3..25aced1a08e 100644 --- a/plugins/module_utils/cloud.py +++ b/plugins/module_utils/cloud.py @@ -26,9 +26,6 @@ # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import time import functools import random diff --git a/plugins/module_utils/cloudfront_facts.py b/plugins/module_utils/cloudfront_facts.py index c628bff14ba..36e3603f3a7 100644 --- a/plugins/module_utils/cloudfront_facts.py +++ b/plugins/module_utils/cloudfront_facts.py @@ -26,9 +26,6 @@ Common cloudfront facts shared between modules """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - try: import botocore except ImportError: @@ -38,7 +35,7 @@ from .ec2 import boto3_tag_list_to_ansible_dict -class CloudFrontFactsServiceManager(object): +class CloudFrontFactsServiceManager: """Handles CloudFront Facts Services""" def __init__(self, module): diff --git a/plugins/module_utils/core.py b/plugins/module_utils/core.py index 9fd4d420f3b..69cb78de2a8 100644 --- a/plugins/module_utils/core.py +++ b/plugins/module_utils/core.py @@ -50,9 +50,6 @@ don't need to be wrapped in the backoff decorator. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.arn from .arn import parse_aws_arn # pylint: disable=unused-import diff --git a/plugins/module_utils/direct_connect.py b/plugins/module_utils/direct_connect.py index abcbcfd232d..371a938ae03 100644 --- a/plugins/module_utils/direct_connect.py +++ b/plugins/module_utils/direct_connect.py @@ -29,9 +29,6 @@ This module adds shared support for Direct Connect modules. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import traceback try: diff --git a/plugins/module_utils/ec2.py b/plugins/module_utils/ec2.py index 817c12298de..8f8bb8b3fdf 100644 --- a/plugins/module_utils/ec2.py +++ b/plugins/module_utils/ec2.py @@ -35,9 +35,6 @@ up in this module because "that's where the AWS code was" (originally). """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import re from ansible.module_utils.ansible_release import __version__ diff --git a/plugins/module_utils/elb_utils.py b/plugins/module_utils/elb_utils.py index 218052d2f12..b6197fc0cf8 100644 --- a/plugins/module_utils/elb_utils.py +++ b/plugins/module_utils/elb_utils.py @@ -1,9 +1,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - try: from botocore.exceptions import BotoCoreError, ClientError except ImportError: diff --git a/plugins/module_utils/elbv2.py b/plugins/module_utils/elbv2.py index 533fd75e23d..7f1b4d8550b 100644 --- a/plugins/module_utils/elbv2.py +++ b/plugins/module_utils/elbv2.py @@ -1,9 +1,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - import traceback from copy import deepcopy @@ -110,7 +107,7 @@ def _sort_actions(actions): return sorted(actions, key=lambda x: x.get('Order', 0)) -class ElasticLoadBalancerV2(object): +class ElasticLoadBalancerV2: def __init__(self, connection, module): @@ -420,7 +417,7 @@ def __init__(self, connection, connection_ec2, module): :param connection: boto3 connection :param module: Ansible module """ - super(ApplicationLoadBalancer, self).__init__(connection, module) + super().__init__(connection, module) self.connection_ec2 = connection_ec2 @@ -588,7 +585,7 @@ def __init__(self, connection, connection_ec2, module): :param connection: boto3 connection :param module: Ansible module """ - super(NetworkLoadBalancer, self).__init__(connection, module) + super().__init__(connection, module) self.connection_ec2 = connection_ec2 @@ -642,7 +639,7 @@ def modify_subnets(self): self.module.fail_json(msg='Modifying subnets and elastic IPs is not supported for Network Load Balancer') -class ELBListeners(object): +class ELBListeners: def __init__(self, connection, module, elb_arn): @@ -802,7 +799,7 @@ def _compare_listener(self, current_listener, new_listener): return None -class ELBListener(object): +class ELBListener: def __init__(self, connection, module, listener, elb_arn): """ @@ -856,7 +853,7 @@ def delete(self): self.module.fail_json_aws(e) -class ELBListenerRules(object): +class ELBListenerRules: def __init__(self, connection, module, elb_arn, listener_rules, listener_port): @@ -1048,7 +1045,7 @@ def compare_rules(self): return rules_to_add, rules_to_modify, rules_to_delete -class ELBListenerRule(object): +class ELBListenerRule: def __init__(self, connection, module, rule, listener_arn): diff --git a/plugins/module_utils/exceptions.py b/plugins/module_utils/exceptions.py index e8a9de2ea72..a091b45cf54 100644 --- a/plugins/module_utils/exceptions.py +++ b/plugins/module_utils/exceptions.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible.module_utils._text import to_native diff --git a/plugins/module_utils/iam.py b/plugins/module_utils/iam.py index 6ebed23baca..86f95ac6bad 100644 --- a/plugins/module_utils/iam.py +++ b/plugins/module_utils/iam.py @@ -1,9 +1,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - try: import botocore except ImportError: diff --git a/plugins/module_utils/modules.py b/plugins/module_utils/modules.py index 19e65221f65..f839f984083 100644 --- a/plugins/module_utils/modules.py +++ b/plugins/module_utils/modules.py @@ -50,15 +50,11 @@ don't need to be wrapped in the backoff decorator. """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import logging import os import re import traceback - try: from cStringIO import StringIO except ImportError: @@ -85,7 +81,7 @@ # for Inventory and Lookup modules which we should refactor -class AnsibleAWSModule(object): +class AnsibleAWSModule: """An ansible module class for AWS modules AnsibleAWSModule provides an a class for building modules which diff --git a/plugins/module_utils/policy.py b/plugins/module_utils/policy.py index a474c7313e9..cc4e71f18da 100644 --- a/plugins/module_utils/policy.py +++ b/plugins/module_utils/policy.py @@ -26,9 +26,6 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from functools import cmp_to_key from ansible.module_utils._text import to_text diff --git a/plugins/module_utils/rds.py b/plugins/module_utils/rds.py index 71981464bfa..3a5a5bc583e 100644 --- a/plugins/module_utils/rds.py +++ b/plugins/module_utils/rds.py @@ -1,9 +1,6 @@ # Copyright: (c) 2018, 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) -__metaclass__ = type - from collections import namedtuple from time import sleep diff --git a/plugins/module_utils/retries.py b/plugins/module_utils/retries.py index 5d101c47849..d50acf55ce4 100644 --- a/plugins/module_utils/retries.py +++ b/plugins/module_utils/retries.py @@ -26,9 +26,6 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from functools import wraps try: @@ -80,7 +77,7 @@ def found(response_code, catch_extra_error_codes=None): return response_code in retry_on -class RetryingBotoClientWrapper(object): +class RetryingBotoClientWrapper: __never_wait = ( 'get_paginator', 'can_paginate', 'get_waiter', 'generate_presigned_url', diff --git a/plugins/module_utils/route53.py b/plugins/module_utils/route53.py index 3e2940a5311..87a9629e916 100644 --- a/plugins/module_utils/route53.py +++ b/plugins/module_utils/route53.py @@ -1,9 +1,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - try: import botocore except ImportError: diff --git a/plugins/module_utils/s3.py b/plugins/module_utils/s3.py index 21afee8d75c..8e10fe4b177 100644 --- a/plugins/module_utils/s3.py +++ b/plugins/module_utils/s3.py @@ -1,9 +1,6 @@ # Copyright (c) 2018 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) -__metaclass__ = type - from ansible.module_utils.basic import to_text from urllib.parse import urlparse diff --git a/plugins/module_utils/tagging.py b/plugins/module_utils/tagging.py index 1568e4887f8..21cc2ce787b 100644 --- a/plugins/module_utils/tagging.py +++ b/plugins/module_utils/tagging.py @@ -26,9 +26,6 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.module_utils._text import to_native from ansible.module_utils._text import to_text from ansible.module_utils.six import string_types diff --git a/plugins/module_utils/tower.py b/plugins/module_utils/tower.py index dd7d9738a5e..a3ec3d7a07e 100644 --- a/plugins/module_utils/tower.py +++ b/plugins/module_utils/tower.py @@ -1,9 +1,6 @@ # 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 -__metaclass__ = type - import string import textwrap diff --git a/plugins/module_utils/transformation.py b/plugins/module_utils/transformation.py index 70d38cd8abb..71374f5d945 100644 --- a/plugins/module_utils/transformation.py +++ b/plugins/module_utils/transformation.py @@ -26,9 +26,6 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible.module_utils.six import string_types from ansible.module_utils.six import integer_types diff --git a/plugins/module_utils/urls.py b/plugins/module_utils/urls.py index 8011a1be9ef..919dab150af 100644 --- a/plugins/module_utils/urls.py +++ b/plugins/module_utils/urls.py @@ -1,9 +1,6 @@ # Copyright: (c) 2018, Aaron Haaf # 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) -__metaclass__ = type - import datetime import hashlib import hmac diff --git a/plugins/module_utils/version.py b/plugins/module_utils/version.py index 8f4ca36389e..890098b1561 100644 --- a/plugins/module_utils/version.py +++ b/plugins/module_utils/version.py @@ -1,15 +1,9 @@ # -*- coding: utf-8 -*- - # Copyright: (c) 2021, Felix Fontein # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """Provide version object to compare version numbers.""" -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - - # Once we drop support for Ansible 2.9, ansible-base 2.10, and ansible-core 2.11, we can # remove the _version.py file, and replace the following import by # diff --git a/plugins/module_utils/waf.py b/plugins/module_utils/waf.py index 226dca920b5..9a17b9634af 100644 --- a/plugins/module_utils/waf.py +++ b/plugins/module_utils/waf.py @@ -29,9 +29,6 @@ This module adds shared support for Web Application Firewall modules """ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - try: import botocore except ImportError: diff --git a/plugins/module_utils/waiters.py b/plugins/module_utils/waiters.py index 6d43be5331d..2112a6c66fd 100644 --- a/plugins/module_utils/waiters.py +++ b/plugins/module_utils/waiters.py @@ -1,9 +1,6 @@ # Copyright: (c) 2018, 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) -__metaclass__ = type - import copy try: diff --git a/plugins/modules/autoscaling_group.py b/plugins/modules/autoscaling_group.py index fda0a66d03c..3862adfb5ad 100644 --- a/plugins/modules/autoscaling_group.py +++ b/plugins/modules/autoscaling_group.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: autoscaling_group diff --git a/plugins/modules/autoscaling_group_info.py b/plugins/modules/autoscaling_group_info.py index 17fc4bec398..2d418f1e940 100644 --- a/plugins/modules/autoscaling_group_info.py +++ b/plugins/modules/autoscaling_group_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: autoscaling_group_info diff --git a/plugins/modules/aws_az_info.py b/plugins/modules/aws_az_info.py index 246321b56e1..659095b8e9f 100644 --- a/plugins/modules/aws_az_info.py +++ b/plugins/modules/aws_az_info.py @@ -2,10 +2,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - - DOCUMENTATION = ''' module: aws_az_info short_description: Gather information about availability zones in AWS diff --git a/plugins/modules/aws_caller_info.py b/plugins/modules/aws_caller_info.py index 3c669160661..772e8cd5566 100644 --- a/plugins/modules/aws_caller_info.py +++ b/plugins/modules/aws_caller_info.py @@ -2,10 +2,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - - DOCUMENTATION = ''' --- module: aws_caller_info diff --git a/plugins/modules/cloudformation.py b/plugins/modules/cloudformation.py index f953a75d267..6e3f62080c2 100644 --- a/plugins/modules/cloudformation.py +++ b/plugins/modules/cloudformation.py @@ -1,12 +1,7 @@ #!/usr/bin/python - # Copyright: (c) 2017, 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudformation diff --git a/plugins/modules/cloudformation_info.py b/plugins/modules/cloudformation_info.py index 89ba80bf790..1697b6af2c5 100644 --- a/plugins/modules/cloudformation_info.py +++ b/plugins/modules/cloudformation_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudformation_info diff --git a/plugins/modules/cloudtrail.py b/plugins/modules/cloudtrail.py index 8ad1cd8bdbf..79ea3c746ba 100644 --- a/plugins/modules/cloudtrail.py +++ b/plugins/modules/cloudtrail.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudtrail diff --git a/plugins/modules/cloudtrail_info.py b/plugins/modules/cloudtrail_info.py index 0429bb7f091..90aa265246b 100644 --- a/plugins/modules/cloudtrail_info.py +++ b/plugins/modules/cloudtrail_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudtrail_info diff --git a/plugins/modules/cloudwatch_metric_alarm.py b/plugins/modules/cloudwatch_metric_alarm.py index 7fdc55a07dc..18112523d37 100644 --- a/plugins/modules/cloudwatch_metric_alarm.py +++ b/plugins/modules/cloudwatch_metric_alarm.py @@ -14,10 +14,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: cloudwatch_metric_alarm short_description: "Create/update or delete AWS CloudWatch 'metric alarms'" diff --git a/plugins/modules/cloudwatch_metric_alarm_info.py b/plugins/modules/cloudwatch_metric_alarm_info.py index 24678b05403..2ddbccb959c 100644 --- a/plugins/modules/cloudwatch_metric_alarm_info.py +++ b/plugins/modules/cloudwatch_metric_alarm_info.py @@ -2,10 +2,6 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://wwww.gnu.org/licenses/gpl-3.0.txt) -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudwatch_metric_alarm_info diff --git a/plugins/modules/cloudwatchevent_rule.py b/plugins/modules/cloudwatchevent_rule.py index 3368ba69a4d..f52c625b250 100644 --- a/plugins/modules/cloudwatchevent_rule.py +++ b/plugins/modules/cloudwatchevent_rule.py @@ -2,10 +2,6 @@ # 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 - -__metaclass__ = type - DOCUMENTATION = r''' --- module: cloudwatchevent_rule @@ -206,7 +202,7 @@ def _format_json(json_string): return str(json.dumps(json_string)) -class CloudWatchEventRule(object): +class CloudWatchEventRule: def __init__(self, module, name, client, schedule_expression=None, event_pattern=None, description=None, role_arn=None): self.name = name @@ -343,7 +339,7 @@ def _snakify(self, dict): return camel_dict_to_snake_dict(dict) -class CloudWatchEventRuleManager(object): +class CloudWatchEventRuleManager: RULE_FIELDS = ['name', 'event_pattern', 'schedule_expression', 'description', 'role_arn'] def __init__(self, rule, targets): diff --git a/plugins/modules/cloudwatchlogs_log_group.py b/plugins/modules/cloudwatchlogs_log_group.py index ec1fdd4e14f..a47dcbfd014 100644 --- a/plugins/modules/cloudwatchlogs_log_group.py +++ b/plugins/modules/cloudwatchlogs_log_group.py @@ -2,11 +2,6 @@ # 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 - -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudwatchlogs_log_group diff --git a/plugins/modules/cloudwatchlogs_log_group_info.py b/plugins/modules/cloudwatchlogs_log_group_info.py index cb4c3808a40..35be8d4aca2 100644 --- a/plugins/modules/cloudwatchlogs_log_group_info.py +++ b/plugins/modules/cloudwatchlogs_log_group_info.py @@ -2,11 +2,6 @@ # 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 - -__metaclass__ = type - - DOCUMENTATION = ''' --- module: cloudwatchlogs_log_group_info diff --git a/plugins/modules/cloudwatchlogs_log_group_metric_filter.py b/plugins/modules/cloudwatchlogs_log_group_metric_filter.py index 82435f4cbfb..5223de5050a 100644 --- a/plugins/modules/cloudwatchlogs_log_group_metric_filter.py +++ b/plugins/modules/cloudwatchlogs_log_group_metric_filter.py @@ -1,9 +1,6 @@ #!/usr/bin/python # 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 -__metaclass__ = type - DOCUMENTATION = ''' --- diff --git a/plugins/modules/ec2_ami.py b/plugins/modules/ec2_ami.py index 2d004289543..639116e9d19 100644 --- a/plugins/modules/ec2_ami.py +++ b/plugins/modules/ec2_ami.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_ami diff --git a/plugins/modules/ec2_ami_info.py b/plugins/modules/ec2_ami_info.py index 3d67e89de6c..d418b059e49 100644 --- a/plugins/modules/ec2_ami_info.py +++ b/plugins/modules/ec2_ami_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_ami_info diff --git a/plugins/modules/ec2_eip.py b/plugins/modules/ec2_eip.py index b0f4ee5452b..30ebb4939cf 100644 --- a/plugins/modules/ec2_eip.py +++ b/plugins/modules/ec2_eip.py @@ -1,13 +1,8 @@ #!/usr/bin/python # -*- coding: utf-8 -*- - # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_eip diff --git a/plugins/modules/ec2_eip_info.py b/plugins/modules/ec2_eip_info.py index c94f164f59f..418768821c0 100644 --- a/plugins/modules/ec2_eip_info.py +++ b/plugins/modules/ec2_eip_info.py @@ -2,10 +2,6 @@ # Copyright (c) 2017 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_eip_info diff --git a/plugins/modules/ec2_eni.py b/plugins/modules/ec2_eni.py index 46c90d54250..b329b695222 100644 --- a/plugins/modules/ec2_eni.py +++ b/plugins/modules/ec2_eni.py @@ -2,10 +2,6 @@ # # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_eni diff --git a/plugins/modules/ec2_eni_info.py b/plugins/modules/ec2_eni_info.py index bf05b017e2e..2ee9f9ee8db 100644 --- a/plugins/modules/ec2_eni_info.py +++ b/plugins/modules/ec2_eni_info.py @@ -2,10 +2,6 @@ # # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_eni_info diff --git a/plugins/modules/ec2_instance.py b/plugins/modules/ec2_instance.py index bd52c404f72..2158bc8c39e 100644 --- a/plugins/modules/ec2_instance.py +++ b/plugins/modules/ec2_instance.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_instance diff --git a/plugins/modules/ec2_instance_info.py b/plugins/modules/ec2_instance_info.py index e1ef2ec4152..3483e536c77 100644 --- a/plugins/modules/ec2_instance_info.py +++ b/plugins/modules/ec2_instance_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_instance_info diff --git a/plugins/modules/ec2_key.py b/plugins/modules/ec2_key.py index 5d849802dee..740a80ee13e 100644 --- a/plugins/modules/ec2_key.py +++ b/plugins/modules/ec2_key.py @@ -3,10 +3,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_key diff --git a/plugins/modules/ec2_metadata_facts.py b/plugins/modules/ec2_metadata_facts.py index b4be52b48ef..015e02a5f88 100644 --- a/plugins/modules/ec2_metadata_facts.py +++ b/plugins/modules/ec2_metadata_facts.py @@ -3,10 +3,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_metadata_facts @@ -450,7 +446,7 @@ socket.setdefaulttimeout(5) -class Ec2Metadata(object): +class Ec2Metadata: ec2_metadata_token_uri = 'http://169.254.169.254/latest/api/token' ec2_metadata_uri = 'http://169.254.169.254/latest/meta-data/' ec2_metadata_instance_tags_uri = 'http://169.254.169.254/latest/meta-data/tags/instance' diff --git a/plugins/modules/ec2_security_group.py b/plugins/modules/ec2_security_group.py index 5ac98f00e7f..dbd91832280 100644 --- a/plugins/modules/ec2_security_group.py +++ b/plugins/modules/ec2_security_group.py @@ -3,10 +3,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_security_group @@ -519,7 +515,7 @@ class SecurityGroupError(Exception): def __init__(self, msg, e=None, **kwargs): - super(SecurityGroupError, self).__init__(msg) + super().__init__(msg) self.message = msg self.exception = e self.kwargs = kwargs diff --git a/plugins/modules/ec2_security_group_info.py b/plugins/modules/ec2_security_group_info.py index 3440f90e8b4..34f9964d03c 100644 --- a/plugins/modules/ec2_security_group_info.py +++ b/plugins/modules/ec2_security_group_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_security_group_info diff --git a/plugins/modules/ec2_snapshot.py b/plugins/modules/ec2_snapshot.py index 62952cf32d2..862996b1464 100644 --- a/plugins/modules/ec2_snapshot.py +++ b/plugins/modules/ec2_snapshot.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_snapshot diff --git a/plugins/modules/ec2_snapshot_info.py b/plugins/modules/ec2_snapshot_info.py index 745edc7fac9..64ed38fd11c 100644 --- a/plugins/modules/ec2_snapshot_info.py +++ b/plugins/modules/ec2_snapshot_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_snapshot_info diff --git a/plugins/modules/ec2_spot_instance.py b/plugins/modules/ec2_spot_instance.py index 99d70bb120f..48a92885053 100644 --- a/plugins/modules/ec2_spot_instance.py +++ b/plugins/modules/ec2_spot_instance.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_spot_instance diff --git a/plugins/modules/ec2_spot_instance_info.py b/plugins/modules/ec2_spot_instance_info.py index 599db778b8b..abc9ee00dff 100644 --- a/plugins/modules/ec2_spot_instance_info.py +++ b/plugins/modules/ec2_spot_instance_info.py @@ -2,10 +2,6 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://wwww.gnu.org/licenses/gpl-3.0.txt) -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_spot_instance_info diff --git a/plugins/modules/ec2_tag.py b/plugins/modules/ec2_tag.py index 6ccf687e37a..2724be58a46 100644 --- a/plugins/modules/ec2_tag.py +++ b/plugins/modules/ec2_tag.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_tag diff --git a/plugins/modules/ec2_tag_info.py b/plugins/modules/ec2_tag_info.py index 6be53656290..35e6b4d8f6a 100644 --- a/plugins/modules/ec2_tag_info.py +++ b/plugins/modules/ec2_tag_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_tag_info diff --git a/plugins/modules/ec2_vol.py b/plugins/modules/ec2_vol.py index 9e6c38a14aa..b1a4b4c1371 100644 --- a/plugins/modules/ec2_vol.py +++ b/plugins/modules/ec2_vol.py @@ -3,10 +3,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vol diff --git a/plugins/modules/ec2_vol_info.py b/plugins/modules/ec2_vol_info.py index 7cd376740f5..a4eec1e10d9 100644 --- a/plugins/modules/ec2_vol_info.py +++ b/plugins/modules/ec2_vol_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vol_info diff --git a/plugins/modules/ec2_vpc_dhcp_option.py b/plugins/modules/ec2_vpc_dhcp_option.py index 8f83812c5e4..dadac0e29cb 100644 --- a/plugins/modules/ec2_vpc_dhcp_option.py +++ b/plugins/modules/ec2_vpc_dhcp_option.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_dhcp_option diff --git a/plugins/modules/ec2_vpc_dhcp_option_info.py b/plugins/modules/ec2_vpc_dhcp_option_info.py index c5058bd7a45..dac64613ff0 100644 --- a/plugins/modules/ec2_vpc_dhcp_option_info.py +++ b/plugins/modules/ec2_vpc_dhcp_option_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_dhcp_option_info diff --git a/plugins/modules/ec2_vpc_endpoint.py b/plugins/modules/ec2_vpc_endpoint.py index 244a6d42e8d..85d0db5d6e3 100644 --- a/plugins/modules/ec2_vpc_endpoint.py +++ b/plugins/modules/ec2_vpc_endpoint.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: ec2_vpc_endpoint short_description: Create and delete AWS VPC endpoints diff --git a/plugins/modules/ec2_vpc_endpoint_info.py b/plugins/modules/ec2_vpc_endpoint_info.py index 5985b249208..b7773bf119b 100644 --- a/plugins/modules/ec2_vpc_endpoint_info.py +++ b/plugins/modules/ec2_vpc_endpoint_info.py @@ -1,10 +1,6 @@ #!/usr/bin/python # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: ec2_vpc_endpoint_info short_description: Retrieves AWS VPC endpoints details using AWS methods diff --git a/plugins/modules/ec2_vpc_endpoint_service_info.py b/plugins/modules/ec2_vpc_endpoint_service_info.py index fefd394213b..5ce60474667 100644 --- a/plugins/modules/ec2_vpc_endpoint_service_info.py +++ b/plugins/modules/ec2_vpc_endpoint_service_info.py @@ -1,10 +1,6 @@ #!/usr/bin/python # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: ec2_vpc_endpoint_service_info short_description: Retrieves AWS VPC endpoint service details diff --git a/plugins/modules/ec2_vpc_igw.py b/plugins/modules/ec2_vpc_igw.py index 99106b03c0b..b34aa7e4584 100644 --- a/plugins/modules/ec2_vpc_igw.py +++ b/plugins/modules/ec2_vpc_igw.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_igw @@ -110,7 +106,7 @@ def describe_igws_with_backoff(connection, **params): return paginator.paginate(**params).build_full_result()['InternetGateways'] -class AnsibleEc2Igw(): +class AnsibleEc2Igw: def __init__(self, module, results): self._module = module diff --git a/plugins/modules/ec2_vpc_igw_info.py b/plugins/modules/ec2_vpc_igw_info.py index 5e7c1a0afb0..53d724b9628 100644 --- a/plugins/modules/ec2_vpc_igw_info.py +++ b/plugins/modules/ec2_vpc_igw_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_vpc_igw_info diff --git a/plugins/modules/ec2_vpc_nat_gateway.py b/plugins/modules/ec2_vpc_nat_gateway.py index e818998ff5b..8cba39cbbbf 100644 --- a/plugins/modules/ec2_vpc_nat_gateway.py +++ b/plugins/modules/ec2_vpc_nat_gateway.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_vpc_nat_gateway diff --git a/plugins/modules/ec2_vpc_nat_gateway_info.py b/plugins/modules/ec2_vpc_nat_gateway_info.py index 45c794e809f..1063e6f1bf6 100644 --- a/plugins/modules/ec2_vpc_nat_gateway_info.py +++ b/plugins/modules/ec2_vpc_nat_gateway_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: ec2_vpc_nat_gateway_info short_description: Retrieves AWS VPC Managed Nat Gateway details using AWS methods diff --git a/plugins/modules/ec2_vpc_net.py b/plugins/modules/ec2_vpc_net.py index c7430e9894f..7872eebc6ab 100644 --- a/plugins/modules/ec2_vpc_net.py +++ b/plugins/modules/ec2_vpc_net.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_net diff --git a/plugins/modules/ec2_vpc_net_info.py b/plugins/modules/ec2_vpc_net_info.py index e32b42d832d..776352acde8 100644 --- a/plugins/modules/ec2_vpc_net_info.py +++ b/plugins/modules/ec2_vpc_net_info.py @@ -2,10 +2,6 @@ # # 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) -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_net_info diff --git a/plugins/modules/ec2_vpc_route_table.py b/plugins/modules/ec2_vpc_route_table.py index 583a0a076e6..cb7c6309a18 100644 --- a/plugins/modules/ec2_vpc_route_table.py +++ b/plugins/modules/ec2_vpc_route_table.py @@ -2,10 +2,6 @@ # # 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) -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_vpc_route_table diff --git a/plugins/modules/ec2_vpc_route_table_info.py b/plugins/modules/ec2_vpc_route_table_info.py index b7b3c69d49b..0e44a7335e2 100644 --- a/plugins/modules/ec2_vpc_route_table_info.py +++ b/plugins/modules/ec2_vpc_route_table_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: ec2_vpc_route_table_info diff --git a/plugins/modules/ec2_vpc_subnet.py b/plugins/modules/ec2_vpc_subnet.py index ae806ae141e..cd7d43bb892 100644 --- a/plugins/modules/ec2_vpc_subnet.py +++ b/plugins/modules/ec2_vpc_subnet.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_subnet diff --git a/plugins/modules/ec2_vpc_subnet_info.py b/plugins/modules/ec2_vpc_subnet_info.py index 94d6c74efcc..15ac155ee1b 100644 --- a/plugins/modules/ec2_vpc_subnet_info.py +++ b/plugins/modules/ec2_vpc_subnet_info.py @@ -2,10 +2,6 @@ # # 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) -__metaclass__ = type - - DOCUMENTATION = ''' --- module: ec2_vpc_subnet_info diff --git a/plugins/modules/elb_application_lb.py b/plugins/modules/elb_application_lb.py index 08d62a7bf10..a8fc7dbea4e 100644 --- a/plugins/modules/elb_application_lb.py +++ b/plugins/modules/elb_application_lb.py @@ -14,10 +14,6 @@ # 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) -__metaclass__ = type - - DOCUMENTATION = r''' --- module: elb_application_lb diff --git a/plugins/modules/elb_application_lb_info.py b/plugins/modules/elb_application_lb_info.py index 42ad25a85c7..809ee49cb7f 100644 --- a/plugins/modules/elb_application_lb_info.py +++ b/plugins/modules/elb_application_lb_info.py @@ -2,9 +2,6 @@ # 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 -__metaclass__ = type - DOCUMENTATION = r''' --- diff --git a/plugins/modules/elb_classic_lb.py b/plugins/modules/elb_classic_lb.py index 5d49d92f625..39aaf7df9d1 100644 --- a/plugins/modules/elb_classic_lb.py +++ b/plugins/modules/elb_classic_lb.py @@ -2,9 +2,6 @@ # 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 -__metaclass__ = type - DOCUMENTATION = ''' --- @@ -692,7 +689,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter -class ElbManager(object): +class ElbManager: """Handles ELB creation and destruction""" def __init__(self, module): diff --git a/plugins/modules/iam_policy.py b/plugins/modules/iam_policy.py index 8eef403042c..43e3409d983 100644 --- a/plugins/modules/iam_policy.py +++ b/plugins/modules/iam_policy.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - - DOCUMENTATION = ''' --- module: iam_policy diff --git a/plugins/modules/iam_policy_info.py b/plugins/modules/iam_policy_info.py index 125f55e1f2d..df8650ac3bd 100644 --- a/plugins/modules/iam_policy_info.py +++ b/plugins/modules/iam_policy_info.py @@ -2,9 +2,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - DOCUMENTATION = ''' --- diff --git a/plugins/modules/iam_user.py b/plugins/modules/iam_user.py index a4e056c0ebf..7e0f2e3f8dd 100644 --- a/plugins/modules/iam_user.py +++ b/plugins/modules/iam_user.py @@ -2,10 +2,6 @@ # Copyright (c) 2017 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: iam_user diff --git a/plugins/modules/iam_user_info.py b/plugins/modules/iam_user_info.py index e9c95edcaeb..8a1a1218d40 100644 --- a/plugins/modules/iam_user_info.py +++ b/plugins/modules/iam_user_info.py @@ -1,12 +1,8 @@ #!/usr/bin/python - # -*- coding: utf-8 -*- # Copyright: (c) 2018, 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 -__metaclass__ = type - DOCUMENTATION = ''' --- diff --git a/plugins/modules/kms_key.py b/plugins/modules/kms_key.py index e947497e405..62b558d4bfc 100644 --- a/plugins/modules/kms_key.py +++ b/plugins/modules/kms_key.py @@ -2,10 +2,6 @@ # -*- coding: utf-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) -__metaclass__ = type - - DOCUMENTATION = r''' --- module: kms_key diff --git a/plugins/modules/kms_key_info.py b/plugins/modules/kms_key_info.py index bc888d34f49..8e5d971cf01 100644 --- a/plugins/modules/kms_key_info.py +++ b/plugins/modules/kms_key_info.py @@ -2,10 +2,6 @@ # # 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) -__metaclass__ = type - - DOCUMENTATION = r''' --- module: kms_key_info diff --git a/plugins/modules/lambda.py b/plugins/modules/lambda.py index a87fe593b86..d0ad82f371c 100644 --- a/plugins/modules/lambda.py +++ b/plugins/modules/lambda.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: lambda diff --git a/plugins/modules/lambda_alias.py b/plugins/modules/lambda_alias.py index e2dd776d653..4615325c80e 100644 --- a/plugins/modules/lambda_alias.py +++ b/plugins/modules/lambda_alias.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_alias diff --git a/plugins/modules/lambda_event.py b/plugins/modules/lambda_event.py index 0f51abc6b9a..260de88bff3 100644 --- a/plugins/modules/lambda_event.py +++ b/plugins/modules/lambda_event.py @@ -2,10 +2,6 @@ # (c) 2016, Pierre Jodouin # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_event diff --git a/plugins/modules/lambda_execute.py b/plugins/modules/lambda_execute.py index 76faae42ddc..85ed8892408 100644 --- a/plugins/modules/lambda_execute.py +++ b/plugins/modules/lambda_execute.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_execute diff --git a/plugins/modules/lambda_info.py b/plugins/modules/lambda_info.py index 18946e4ae5e..228804a2128 100644 --- a/plugins/modules/lambda_info.py +++ b/plugins/modules/lambda_info.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_info diff --git a/plugins/modules/lambda_layer.py b/plugins/modules/lambda_layer.py index 905e0879044..c4bbee28df3 100644 --- a/plugins/modules/lambda_layer.py +++ b/plugins/modules/lambda_layer.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_layer diff --git a/plugins/modules/lambda_layer_info.py b/plugins/modules/lambda_layer_info.py index 74f8d81fd63..2d2ab3c9f32 100644 --- a/plugins/modules/lambda_layer_info.py +++ b/plugins/modules/lambda_layer_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_layer_info diff --git a/plugins/modules/lambda_policy.py b/plugins/modules/lambda_policy.py index 38fbef325bd..b8aee7e4019 100644 --- a/plugins/modules/lambda_policy.py +++ b/plugins/modules/lambda_policy.py @@ -3,10 +3,6 @@ # Copyright (c) 2017 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: lambda_policy diff --git a/plugins/modules/rds_cluster.py b/plugins/modules/rds_cluster.py index dcb9594188d..5fafbc4289b 100644 --- a/plugins/modules/rds_cluster.py +++ b/plugins/modules/rds_cluster.py @@ -3,10 +3,6 @@ # Copyright (c) 2022 Alina Buzachis (@alinabuzachis) # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: rds_cluster diff --git a/plugins/modules/rds_cluster_info.py b/plugins/modules/rds_cluster_info.py index 3135a4ce91f..b32fdb9e13e 100644 --- a/plugins/modules/rds_cluster_info.py +++ b/plugins/modules/rds_cluster_info.py @@ -3,10 +3,6 @@ # Copyright (c) 2022 Alina Buzachis (@alinabuzachis) # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: rds_cluster_info version_added: 5.0.0 diff --git a/plugins/modules/rds_cluster_snapshot.py b/plugins/modules/rds_cluster_snapshot.py index f258066fbae..f66f482cb84 100644 --- a/plugins/modules/rds_cluster_snapshot.py +++ b/plugins/modules/rds_cluster_snapshot.py @@ -3,10 +3,6 @@ # Copyright (c) 2021 Alina Buzachis (@alinabuzachis) # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: rds_cluster_snapshot diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index 4ec1c125a03..393b04ad13b 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -2,10 +2,6 @@ # Copyright (c) 2018 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: rds_instance diff --git a/plugins/modules/rds_instance_info.py b/plugins/modules/rds_instance_info.py index 486394643cd..cedca9e855e 100644 --- a/plugins/modules/rds_instance_info.py +++ b/plugins/modules/rds_instance_info.py @@ -4,10 +4,6 @@ # Copyright (c) 2017 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: rds_instance_info diff --git a/plugins/modules/rds_instance_snapshot.py b/plugins/modules/rds_instance_snapshot.py index fc63cea0aae..1ccc64b2984 100644 --- a/plugins/modules/rds_instance_snapshot.py +++ b/plugins/modules/rds_instance_snapshot.py @@ -4,10 +4,6 @@ # Copyright (c) 2017, 2018 Michael De La Rue # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: rds_instance_snapshot diff --git a/plugins/modules/rds_option_group.py b/plugins/modules/rds_option_group.py index 846581b85c4..da8647a7ee2 100644 --- a/plugins/modules/rds_option_group.py +++ b/plugins/modules/rds_option_group.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: rds_option_group short_description: Manages the creation, modification, deletion of RDS option groups diff --git a/plugins/modules/rds_option_group_info.py b/plugins/modules/rds_option_group_info.py index 532ef5c12c7..769471e8bc9 100644 --- a/plugins/modules/rds_option_group_info.py +++ b/plugins/modules/rds_option_group_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' --- module: rds_option_group_info diff --git a/plugins/modules/rds_param_group.py b/plugins/modules/rds_param_group.py index 12deba6186d..b13a1c32371 100644 --- a/plugins/modules/rds_param_group.py +++ b/plugins/modules/rds_param_group.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: rds_param_group diff --git a/plugins/modules/rds_snapshot_info.py b/plugins/modules/rds_snapshot_info.py index a9c69ce9519..a3fdd04f216 100644 --- a/plugins/modules/rds_snapshot_info.py +++ b/plugins/modules/rds_snapshot_info.py @@ -4,10 +4,6 @@ # Copyright (c) 2017, 2018 Michael De La Rue # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: rds_snapshot_info diff --git a/plugins/modules/rds_subnet_group.py b/plugins/modules/rds_subnet_group.py index 4aae74acda3..4d112007cd6 100644 --- a/plugins/modules/rds_subnet_group.py +++ b/plugins/modules/rds_subnet_group.py @@ -1,14 +1,8 @@ #!/usr/bin/python # -*- coding: utf-8 -*- - # 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 - -__metaclass__ = type - - DOCUMENTATION = r''' --- module: rds_subnet_group diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index 3ac321763b1..a38e08eb2e5 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -1,14 +1,8 @@ #!/usr/bin/python # -*- coding: utf-8 -*- - # Copyright: (c) 2018, 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 - -__metaclass__ = type - - DOCUMENTATION = r''' --- module: route53 diff --git a/plugins/modules/route53_health_check.py b/plugins/modules/route53_health_check.py index 86b2df14ca2..0b6b1cccdd1 100644 --- a/plugins/modules/route53_health_check.py +++ b/plugins/modules/route53_health_check.py @@ -2,10 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - - DOCUMENTATION = ''' --- module: route53_health_check diff --git a/plugins/modules/route53_info.py b/plugins/modules/route53_info.py index a2a83c6cb86..7835fb18fff 100644 --- a/plugins/modules/route53_info.py +++ b/plugins/modules/route53_info.py @@ -2,10 +2,6 @@ # 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 -__metaclass__ = type - - DOCUMENTATION = r''' module: route53_info short_description: Retrieves route53 details using AWS methods diff --git a/plugins/modules/route53_zone.py b/plugins/modules/route53_zone.py index 2cc9798062a..1f9dc3803f8 100644 --- a/plugins/modules/route53_zone.py +++ b/plugins/modules/route53_zone.py @@ -2,9 +2,6 @@ # This file is part of Ansible # 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 -__metaclass__ = type - DOCUMENTATION = r''' module: route53_zone short_description: add or delete Route53 zones diff --git a/plugins/modules/s3_bucket.py b/plugins/modules/s3_bucket.py index f4860900b5b..5e66af4e396 100644 --- a/plugins/modules/s3_bucket.py +++ b/plugins/modules/s3_bucket.py @@ -13,10 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this library. If not, see . -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - - DOCUMENTATION = r''' --- module: s3_bucket diff --git a/plugins/modules/s3_object.py b/plugins/modules/s3_object.py index 4a06acc9326..0117ea682f1 100644 --- a/plugins/modules/s3_object.py +++ b/plugins/modules/s3_object.py @@ -2,11 +2,6 @@ # This file is part of Ansible # 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 - -__metaclass__ = type - - DOCUMENTATION = """ --- module: s3_object diff --git a/plugins/modules/s3_object_info.py b/plugins/modules/s3_object_info.py index 5a98831fcac..eaf93a6785c 100644 --- a/plugins/modules/s3_object_info.py +++ b/plugins/modules/s3_object_info.py @@ -2,10 +2,6 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://wwww.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - - DOCUMENTATION = r''' --- module: s3_object_info diff --git a/plugins/plugin_utils/base.py b/plugins/plugin_utils/base.py index 351faed2011..8491c085883 100644 --- a/plugins/plugin_utils/base.py +++ b/plugins/plugin_utils/base.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible.errors import AnsibleError from ansible.module_utils.basic import to_native from ansible.utils.display import Display @@ -20,7 +17,7 @@ display = Display() -class AWSPluginBase(): +class AWSPluginBase: def warn(self, message): display.warning(message) diff --git a/plugins/plugin_utils/lookup.py b/plugins/plugin_utils/lookup.py index 7e07d0caf77..18b152bd326 100644 --- a/plugins/plugin_utils/lookup.py +++ b/plugins/plugin_utils/lookup.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible.errors import AnsibleLookupError from ansible.plugins.lookup import LookupBase diff --git a/tests/unit/compat/__init__.py b/tests/unit/__init__.py similarity index 100% rename from tests/unit/compat/__init__.py rename to tests/unit/__init__.py diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py deleted file mode 100644 index 349d310e86d..00000000000 --- a/tests/unit/compat/builtins.py +++ /dev/null @@ -1,33 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -# -# Compat for python2.7 -# - -# One unittest needs to import builtins via __import__() so we need to have -# the string that represents it -try: - import __builtin__ # pylint: disable=unused-import -except ImportError: - BUILTINS = 'builtins' -else: - BUILTINS = '__builtin__' diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py deleted file mode 100644 index 0972cd2e8e5..00000000000 --- a/tests/unit/compat/mock.py +++ /dev/null @@ -1,122 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -''' -Compat module for Python3.x's unittest.mock module -''' -import sys - -# Python 2.7 - -# Note: Could use the pypi mock library on python3.x as well as python2.x. It -# is the same as the python3 stdlib mock library - -try: - # Allow wildcard import because we really do want to import all of mock's - # symbols into this compat shim - # pylint: disable=wildcard-import,unused-wildcard-import - from unittest.mock import * -except ImportError: - # Python 2 - # pylint: disable=wildcard-import,unused-wildcard-import - try: - from mock import * - except ImportError: - print('You need the mock library installed on python2.x to run tests') - - -# Prior to 3.4.4, mock_open cannot handle binary read_data -if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): - file_spec = None - - def _iterate_read_data(read_data): - # Helper for mock_open: - # Retrieve lines from read_data via a generator so that separate calls to - # readline, read, and readlines are properly interleaved - sep = b'\n' if isinstance(read_data, bytes) else '\n' - data_as_list = [l + sep for l in read_data.split(sep)] - - if data_as_list[-1] == sep: - # If the last line ended in a newline, the list comprehension will have an - # extra entry that's just a newline. Remove this. - data_as_list = data_as_list[:-1] - else: - # If there wasn't an extra newline by itself, then the file being - # emulated doesn't have a newline to end the last line remove the - # newline that our naive format() added - data_as_list[-1] = data_as_list[-1][:-1] - - for line in data_as_list: - yield line - - def mock_open(mock=None, read_data=''): - """ - A helper function to create a mock to replace the use of `open`. It works - for `open` called directly or used as a context manager. - - The `mock` argument is the mock object to configure. If `None` (the - default) then a `MagicMock` will be created for you, with the API limited - to methods or attributes available on standard file handles. - - `read_data` is a string for the `read` methoddline`, and `readlines` of the - file handle to return. This is an empty string by default. - """ - def _readlines_side_effect(*args, **kwargs): - if handle.readlines.return_value is not None: - return handle.readlines.return_value - return list(_data) - - def _read_side_effect(*args, **kwargs): - if handle.read.return_value is not None: - return handle.read.return_value - return type(read_data)().join(_data) - - def _readline_side_effect(): - if handle.readline.return_value is not None: - while True: - yield handle.readline.return_value - for line in _data: - yield line - - global file_spec - if file_spec is None: - import _io - file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) - - if mock is None: - mock = MagicMock(name='open', spec=open) - - handle = MagicMock(spec=file_spec) - handle.__enter__.return_value = handle - - _data = _iterate_read_data(read_data) - - handle.write.return_value = None - handle.read.return_value = None - handle.readline.return_value = None - handle.readlines.return_value = None - - handle.read.side_effect = _read_side_effect - handle.readline.side_effect = _readline_side_effect() - handle.readlines.side_effect = _readlines_side_effect - - mock.return_value = handle - return mock diff --git a/tests/unit/compat/unittest.py b/tests/unit/compat/unittest.py deleted file mode 100644 index 98f08ad6a84..00000000000 --- a/tests/unit/compat/unittest.py +++ /dev/null @@ -1,38 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -''' -Compat module for Python2.7's unittest module -''' - -import sys - -# Allow wildcard import because we really do want to import all of -# unittests's symbols into this compat shim -# pylint: disable=wildcard-import,unused-wildcard-import -if sys.version_info < (2, 7): - try: - # Need unittest2 on python2.6 - from unittest2 import * - except ImportError: - print('You need unittest2 installed on python2.6.x to run tests') -else: - from unittest import * diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py deleted file mode 100644 index 00a5841274b..00000000000 --- a/tests/unit/mock/loader.py +++ /dev/null @@ -1,116 +0,0 @@ -# (c) 2012-2014, Michael DeHaan -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import os - -from ansible.errors import AnsibleParserError -from ansible.parsing.dataloader import DataLoader -from ansible.module_utils._text import to_bytes, to_text - - -class DictDataLoader(DataLoader): - - def __init__(self, file_mapping=None): - file_mapping = {} if file_mapping is None else file_mapping - assert type(file_mapping) == dict - - super(DictDataLoader, self).__init__() - - self._file_mapping = file_mapping - self._build_known_directories() - self._vault_secrets = None - - def load_from_file(self, path, cache=True, unsafe=False): - path = to_text(path) - if path in self._file_mapping: - return self.load(self._file_mapping[path], path) - return None - - # TODO: the real _get_file_contents returns a bytestring, so we actually convert the - # unicode/text it's created with to utf-8 - def _get_file_contents(self, file_name): - file_name = to_text(file_name) - if file_name in self._file_mapping: - return (to_bytes(self._file_mapping[file_name]), False) - else: - raise AnsibleParserError("file not found: %s" % file_name) - - def path_exists(self, path): - path = to_text(path) - return path in self._file_mapping or path in self._known_directories - - def is_file(self, path): - path = to_text(path) - return path in self._file_mapping - - def is_directory(self, path): - path = to_text(path) - return path in self._known_directories - - def list_directory(self, path): - ret = [] - path = to_text(path) - for x in (list(self._file_mapping.keys()) + self._known_directories): - if x.startswith(path): - if os.path.dirname(x) == path: - ret.append(os.path.basename(x)) - return ret - - def is_executable(self, path): - # FIXME: figure out a way to make paths return true for this - return False - - def _add_known_directory(self, directory): - if directory not in self._known_directories: - self._known_directories.append(directory) - - def _build_known_directories(self): - self._known_directories = [] - for path in self._file_mapping: - dirname = os.path.dirname(path) - while dirname not in ('/', ''): - self._add_known_directory(dirname) - dirname = os.path.dirname(dirname) - - def push(self, path, content): - rebuild_dirs = False - if path not in self._file_mapping: - rebuild_dirs = True - - self._file_mapping[path] = content - - if rebuild_dirs: - self._build_known_directories() - - def pop(self, path): - if path in self._file_mapping: - del self._file_mapping[path] - self._build_known_directories() - - def clear(self): - self._file_mapping = dict() - self._known_directories = [] - - def get_basedir(self): - return os.getcwd() - - def set_vault_secrets(self, vault_secrets): - self._vault_secrets = vault_secrets diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py deleted file mode 100644 index 8de2aec25ce..00000000000 --- a/tests/unit/mock/path.py +++ /dev/null @@ -1,8 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock -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 deleted file mode 100644 index 273959e4b24..00000000000 --- a/tests/unit/mock/procenv.py +++ /dev/null @@ -1,90 +0,0 @@ -# (c) 2016, Matt Davis -# (c) 2016, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import sys -import json - -from contextlib import contextmanager -from io import BytesIO, StringIO -from ansible_collections.amazon.aws.tests.unit.compat import unittest -from ansible.module_utils.six import PY3 -from ansible.module_utils._text import to_bytes - - -@contextmanager -def swap_stdin_and_argv(stdin_data='', argv_data=tuple()): - """ - context manager that temporarily masks the test runner's values for stdin and argv - """ - real_stdin = sys.stdin - real_argv = sys.argv - - if PY3: - fake_stream = StringIO(stdin_data) - fake_stream.buffer = BytesIO(to_bytes(stdin_data)) - else: - fake_stream = BytesIO(to_bytes(stdin_data)) - - try: - sys.stdin = fake_stream - sys.argv = argv_data - - yield - finally: - sys.stdin = real_stdin - sys.argv = real_argv - - -@contextmanager -def swap_stdout(): - """ - context manager that temporarily replaces stdout for tests that need to verify output - """ - old_stdout = sys.stdout - - if PY3: - fake_stream = StringIO() - else: - fake_stream = BytesIO() - - try: - sys.stdout = fake_stream - - yield fake_stream - finally: - sys.stdout = old_stdout - - -class ModuleTestCase(unittest.TestCase): - def setUp(self, module_args=None): - if module_args is None: - module_args = {'_ansible_remote_tmp': '/tmp', '_ansible_keep_remote_files': False} - - args = json.dumps(dict(ANSIBLE_MODULE_ARGS=module_args)) - - # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually - self.stdin_swap = swap_stdin_and_argv(stdin_data=args) - self.stdin_swap.__enter__() - - def tearDown(self): - # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually - self.stdin_swap.__exit__(None, None, None) diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py deleted file mode 100644 index dcce9c78415..00000000000 --- a/tests/unit/mock/vault_helper.py +++ /dev/null @@ -1,39 +0,0 @@ -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.module_utils._text import to_bytes - -from ansible.parsing.vault import VaultSecret - - -class TextVaultSecret(VaultSecret): - '''A secret piece of text. ie, a password. Tracks text encoding. - - The text encoding of the text may not be the default text encoding so - we keep track of the encoding so we encode it to the same bytes.''' - - def __init__(self, text, encoding=None, errors=None, _bytes=None): - super(TextVaultSecret, self).__init__() - self.text = text - self.encoding = encoding or 'utf-8' - self._bytes = _bytes - self.errors = errors or 'strict' - - @property - def bytes(self): - '''The text encoded with encoding, unless we specifically set _bytes.''' - return self._bytes or to_bytes(self.text, encoding=self.encoding, errors=self.errors) diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py deleted file mode 100644 index 1ef172159d4..00000000000 --- a/tests/unit/mock/yaml_helper.py +++ /dev/null @@ -1,124 +0,0 @@ -from __future__ import (absolute_import, division, 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 - - -class YamlTestUtils(object): - """Mixin class to combine with a unittest.TestCase subclass.""" - def _loader(self, stream): - """Vault related tests will want to override this. - - Vault cases should setup a AnsibleLoader that has the vault password.""" - return AnsibleLoader(stream) - - def _dump_stream(self, obj, stream, dumper=None): - """Dump to a py2-unicode or py3-string stream.""" - if PY3: - return yaml.dump(obj, stream, Dumper=dumper) - else: - return yaml.dump(obj, stream, Dumper=dumper, encoding=None) - - def _dump_string(self, obj, dumper=None): - """Dump to a py2-unicode or py3-string""" - if PY3: - return yaml.dump(obj, Dumper=dumper) - else: - return yaml.dump(obj, Dumper=dumper, encoding=None) - - def _dump_load_cycle(self, obj): - # Each pass though a dump or load revs the 'generation' - # obj to yaml string - string_from_object_dump = self._dump_string(obj, dumper=AnsibleDumper) - - # wrap a stream/file like StringIO around that yaml - stream_from_object_dump = io.StringIO(string_from_object_dump) - loader = self._loader(stream_from_object_dump) - # load the yaml stream to create a new instance of the object (gen 2) - obj_2 = loader.get_data() - - # dump the gen 2 objects directory to strings - string_from_object_dump_2 = self._dump_string(obj_2, - dumper=AnsibleDumper) - - # The gen 1 and gen 2 yaml strings - self.assertEqual(string_from_object_dump, string_from_object_dump_2) - # the gen 1 (orig) and gen 2 py object - self.assertEqual(obj, obj_2) - - # again! gen 3... load strings into py objects - stream_3 = io.StringIO(string_from_object_dump_2) - loader_3 = self._loader(stream_3) - obj_3 = loader_3.get_data() - - string_from_object_dump_3 = self._dump_string(obj_3, dumper=AnsibleDumper) - - self.assertEqual(obj, obj_3) - # should be transitive, but... - self.assertEqual(obj_2, obj_3) - self.assertEqual(string_from_object_dump, string_from_object_dump_3) - - def _old_dump_load_cycle(self, obj): - '''Dump the passed in object to yaml, load it back up, dump again, compare.''' - stream = io.StringIO() - - yaml_string = self._dump_string(obj, dumper=AnsibleDumper) - self._dump_stream(obj, stream, dumper=AnsibleDumper) - - yaml_string_from_stream = stream.getvalue() - - # reset stream - stream.seek(0) - - loader = self._loader(stream) - # loader = AnsibleLoader(stream, vault_password=self.vault_password) - obj_from_stream = loader.get_data() - - stream_from_string = io.StringIO(yaml_string) - loader2 = self._loader(stream_from_string) - # loader2 = AnsibleLoader(stream_from_string, vault_password=self.vault_password) - obj_from_string = loader2.get_data() - - stream_obj_from_stream = io.StringIO() - stream_obj_from_string = io.StringIO() - - if PY3: - yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper) - yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper) - else: - yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper, encoding=None) - yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper, encoding=None) - - yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue() - yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue() - - stream_obj_from_stream.seek(0) - stream_obj_from_string.seek(0) - - if PY3: - yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper) - yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper) - else: - yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper, encoding=None) - yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper, encoding=None) - - assert yaml_string == yaml_string_obj_from_stream - assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string - assert (yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string == yaml_string_stream_obj_from_stream == - yaml_string_stream_obj_from_string) - assert obj == obj_from_stream - assert obj == obj_from_string - assert obj == yaml_string_obj_from_stream - assert obj == yaml_string_obj_from_string - assert obj == obj_from_stream == obj_from_string == yaml_string_obj_from_stream == yaml_string_obj_from_string - return {'obj': obj, - 'yaml_string': yaml_string, - 'yaml_string_from_stream': yaml_string_from_stream, - 'obj_from_stream': obj_from_stream, - 'obj_from_string': obj_from_string, - 'yaml_string_obj_from_string': yaml_string_obj_from_string} diff --git a/tests/unit/module_utils/__init__.py b/tests/unit/module_utils/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/arn/__init__.py b/tests/unit/module_utils/arn/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/arn/test_is_outpost_arn.py b/tests/unit/module_utils/arn/test_is_outpost_arn.py index 7c2e21eb28b..8b92c4cca9d 100644 --- a/tests/unit/module_utils/arn/test_is_outpost_arn.py +++ b/tests/unit/module_utils/arn/test_is_outpost_arn.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils.arn import is_outpost_arn diff --git a/tests/unit/module_utils/arn/test_parse_aws_arn.py b/tests/unit/module_utils/arn/test_parse_aws_arn.py index 87dada4a916..94f9aa18cf8 100644 --- a/tests/unit/module_utils/arn/test_parse_aws_arn.py +++ b/tests/unit/module_utils/arn/test_parse_aws_arn.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils.arn import parse_aws_arn diff --git a/tests/unit/module_utils/botocore/__init__.py b/tests/unit/module_utils/botocore/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/botocore/test_aws_region.py b/tests/unit/module_utils/botocore/test_aws_region.py index 2d68f95ac3a..ae8f6efadb1 100644 --- a/tests/unit/module_utils/botocore/test_aws_region.py +++ b/tests/unit/module_utils/botocore/test_aws_region.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import MagicMock from unittest.mock import sentinel diff --git a/tests/unit/module_utils/botocore/test_boto3_conn.py b/tests/unit/module_utils/botocore/test_boto3_conn.py index 52cc235ed29..08676ffd1ee 100644 --- a/tests/unit/module_utils/botocore/test_boto3_conn.py +++ b/tests/unit/module_utils/botocore/test_boto3_conn.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - try: import botocore except ImportError: diff --git a/tests/unit/module_utils/botocore/test_connection_info.py b/tests/unit/module_utils/botocore/test_connection_info.py index 36ce449876f..04c307205d0 100644 --- a/tests/unit/module_utils/botocore/test_connection_info.py +++ b/tests/unit/module_utils/botocore/test_connection_info.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from copy import deepcopy import pytest from unittest.mock import MagicMock diff --git a/tests/unit/module_utils/botocore/test_is_boto3_error_code.py b/tests/unit/module_utils/botocore/test_is_boto3_error_code.py index 627ae4cb3b2..ed661ade788 100644 --- a/tests/unit/module_utils/botocore/test_is_boto3_error_code.py +++ b/tests/unit/module_utils/botocore/test_is_boto3_error_code.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest try: @@ -22,7 +19,7 @@ pytestmark = pytest.mark.skip("test_is_boto3_error_code.py requires the python modules 'boto3' and 'botocore'") -class TestIsBoto3ErrorCode(): +class TestIsBoto3ErrorCode: def _make_denied_exception(self): return botocore.exceptions.ClientError( diff --git a/tests/unit/module_utils/botocore/test_is_boto3_error_message.py b/tests/unit/module_utils/botocore/test_is_boto3_error_message.py index cd40a58dd2f..11404e47d81 100644 --- a/tests/unit/module_utils/botocore/test_is_boto3_error_message.py +++ b/tests/unit/module_utils/botocore/test_is_boto3_error_message.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest try: @@ -22,7 +19,7 @@ pytestmark = pytest.mark.skip("test_is_boto3_error_message.py requires the python modules 'boto3' and 'botocore'") -class TestIsBoto3ErrorMessaged(): +class TestIsBoto3ErrorMessaged: def _make_denied_exception(self): return botocore.exceptions.ClientError( diff --git a/tests/unit/module_utils/botocore/test_normalize_boto3_result.py b/tests/unit/module_utils/botocore/test_normalize_boto3_result.py index 71da9d66d8a..5aec656b395 100644 --- a/tests/unit/module_utils/botocore/test_normalize_boto3_result.py +++ b/tests/unit/module_utils/botocore/test_normalize_boto3_result.py @@ -1,6 +1,3 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result diff --git a/tests/unit/module_utils/botocore/test_sdk_versions.py b/tests/unit/module_utils/botocore/test_sdk_versions.py index 4a6a4c7ff3f..b4511ff6b56 100644 --- a/tests/unit/module_utils/botocore/test_sdk_versions.py +++ b/tests/unit/module_utils/botocore/test_sdk_versions.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest import warnings from unittest.mock import sentinel diff --git a/tests/unit/module_utils/cloud/__init__.py b/tests/unit/module_utils/cloud/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/cloud/test_backoff_iterator.py b/tests/unit/module_utils/cloud/test_backoff_iterator.py index 5fee115c230..5572f406e26 100644 --- a/tests/unit/module_utils/cloud/test_backoff_iterator.py +++ b/tests/unit/module_utils/cloud/test_backoff_iterator.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils.cloud import BackoffIterator diff --git a/tests/unit/module_utils/cloud/test_cloud_retry.py b/tests/unit/module_utils/cloud/test_cloud_retry.py index d627566dc03..83a876dd5f2 100644 --- a/tests/unit/module_utils/cloud/test_cloud_retry.py +++ b/tests/unit/module_utils/cloud/test_cloud_retry.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import random from datetime import datetime import pytest @@ -13,7 +10,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.cloud import CloudRetry -class TestCloudRetry(): +class TestCloudRetry: error_codes = [400, 500, 600] custom_error_codes = [100, 200, 300] diff --git a/tests/unit/module_utils/cloud/test_decorator_generation.py b/tests/unit/module_utils/cloud/test_decorator_generation.py index 9550e05b48b..8e7d62720a0 100644 --- a/tests/unit/module_utils/cloud/test_decorator_generation.py +++ b/tests/unit/module_utils/cloud/test_decorator_generation.py @@ -3,16 +3,13 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest import sys +from unittest.mock import MagicMock +from unittest.mock import sentinel from ansible_collections.amazon.aws.plugins.module_utils.cloud import CloudRetry from ansible_collections.amazon.aws.plugins.module_utils.cloud import BackoffIterator -from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock -from ansible_collections.amazon.aws.tests.unit.compat.mock import sentinel if sys.version_info < (3, 8): pytest.skip("accessing call_args.kwargs by keyword (instead of index) was introduced in Python 3.8", allow_module_level=True) diff --git a/tests/unit/module_utils/cloud/test_retries_found.py b/tests/unit/module_utils/cloud/test_retries_found.py index 21ad74d42d4..43a342ef287 100644 --- a/tests/unit/module_utils/cloud/test_retries_found.py +++ b/tests/unit/module_utils/cloud/test_retries_found.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils.cloud import CloudRetry diff --git a/tests/unit/module_utils/cloud/test_retry_func.py b/tests/unit/module_utils/cloud/test_retry_func.py index 609c0718bb9..16cd3dcb997 100644 --- a/tests/unit/module_utils/cloud/test_retry_func.py +++ b/tests/unit/module_utils/cloud/test_retry_func.py @@ -3,15 +3,12 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest import sys +from unittest.mock import Mock +from unittest.mock import sentinel import ansible_collections.amazon.aws.plugins.module_utils.cloud as cloud_utils -from ansible_collections.amazon.aws.tests.unit.compat.mock import Mock -from ansible_collections.amazon.aws.tests.unit.compat.mock import sentinel if sys.version_info < (3, 8): pytest.skip("accessing call_args.kwargs by keyword (instead of index) was introduced in Python 3.8", allow_module_level=True) diff --git a/tests/unit/module_utils/conftest.py b/tests/unit/module_utils/conftest.py index f90055615d1..fee98d2490a 100644 --- a/tests/unit/module_utils/conftest.py +++ b/tests/unit/module_utils/conftest.py @@ -1,9 +1,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - import json import sys from io import BytesIO diff --git a/tests/unit/module_utils/elbv2/__init__.py b/tests/unit/module_utils/elbv2/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/elbv2/test_prune.py b/tests/unit/module_utils/elbv2/test_prune.py index 3a80bf58df8..72d354ecd17 100644 --- a/tests/unit/module_utils/elbv2/test_prune.py +++ b/tests/unit/module_utils/elbv2/test_prune.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils import elbv2 diff --git a/tests/unit/module_utils/exceptions/__init__.py b/tests/unit/module_utils/exceptions/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/exceptions/test_exceptions.py b/tests/unit/module_utils/exceptions/test_exceptions.py index e2dc6510947..2df34eb00ef 100644 --- a/tests/unit/module_utils/exceptions/test_exceptions.py +++ b/tests/unit/module_utils/exceptions/test_exceptions.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import sentinel diff --git a/tests/unit/module_utils/modules/__init__.py b/tests/unit/module_utils/modules/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/modules/ansible_aws_module/__init__.py b/tests/unit/module_utils/modules/ansible_aws_module/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py b/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py index 51e64490f9a..84a81c5cd7a 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import json import pytest @@ -24,7 +21,7 @@ pytestmark = pytest.mark.skip("test_fail_json_aws.py requires the python modules 'boto3' and 'botocore'") -class TestFailJsonAwsTestSuite(object): +class TestFailJsonAwsTestSuite: # ======================================================== # Prepare some data for use in our testing # ======================================================== diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py b/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py index f0bf3c4c853..8540cd32f7e 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from pprint import pprint import pytest import json @@ -23,7 +20,7 @@ pytestmark = pytest.mark.skip("test_minimal_versions.py requires the python modules 'boto3' and 'botocore'") -class TestMinimalVersionTestSuite(object): +class TestMinimalVersionTestSuite: # ======================================================== # Prepare some data for use in our testing # ======================================================== diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py b/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py index 87997a3220a..ec096d532e8 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import call from unittest.mock import MagicMock diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py b/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py index adf2bf558e5..d3bff9bf6a7 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import json import pytest @@ -44,7 +41,7 @@ pytestmark = pytest.mark.skip("test_require_at_least.py requires the python modules 'boto3' and 'botocore'") -class TestRequireAtLeastTestSuite(object): +class TestRequireAtLeastTestSuite: # ======================================================== # Prepare some data for use in our testing # ======================================================== diff --git a/tests/unit/module_utils/policy/__init__.py b/tests/unit/module_utils/policy/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/policy/test_canonicalize.py b/tests/unit/module_utils/policy/test_canonicalize.py index ed8735cdf19..39c06aeea7c 100644 --- a/tests/unit/module_utils/policy/test_canonicalize.py +++ b/tests/unit/module_utils/policy/test_canonicalize.py @@ -3,15 +3,12 @@ # This file is part of Ansible # 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) -__metaclass__ = type +from unittest.mock import sentinel from ansible_collections.amazon.aws.plugins.module_utils.policy import _canonify_root_arn from ansible_collections.amazon.aws.plugins.module_utils.policy import _canonify_policy_dict_item from ansible_collections.amazon.aws.plugins.module_utils.policy import _tuplify_list -from ansible_collections.amazon.aws.tests.unit.compat.mock import sentinel - def test_tuplify_list(): my_list = ["one", 2, sentinel.list_item, False] diff --git a/tests/unit/module_utils/policy/test_compare_policies.py b/tests/unit/module_utils/policy/test_compare_policies.py index eb6de22dbad..66756ccf265 100644 --- a/tests/unit/module_utils/policy/test_compare_policies.py +++ b/tests/unit/module_utils/policy/test_compare_policies.py @@ -3,13 +3,10 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies -class TestComparePolicy(): +class TestComparePolicy: # ======================================================== # Setup some initial data that we can use within our tests diff --git a/tests/unit/module_utils/policy/test_py3cmp.py b/tests/unit/module_utils/policy/test_py3cmp.py index 819befcc7fc..3d9711ac951 100644 --- a/tests/unit/module_utils/policy/test_py3cmp.py +++ b/tests/unit/module_utils/policy/test_py3cmp.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils.policy import _py3cmp diff --git a/tests/unit/module_utils/policy/test_simple_hashable_policy.py b/tests/unit/module_utils/policy/test_simple_hashable_policy.py index 16a10139756..67ae0986478 100644 --- a/tests/unit/module_utils/policy/test_simple_hashable_policy.py +++ b/tests/unit/module_utils/policy/test_simple_hashable_policy.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils.policy import _hashable_policy diff --git a/tests/unit/module_utils/policy/test_sort_json_policy_dict.py b/tests/unit/module_utils/policy/test_sort_json_policy_dict.py index 80031a80ee7..3ae46c7d6df 100644 --- a/tests/unit/module_utils/policy/test_sort_json_policy_dict.py +++ b/tests/unit/module_utils/policy/test_sort_json_policy_dict.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils.policy import sort_json_policy_dict diff --git a/tests/unit/module_utils/retries/__init__.py b/tests/unit/module_utils/retries/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/retries/test_awsretry.py b/tests/unit/module_utils/retries/test_awsretry.py index fa0af4f9f92..6b359e922ca 100644 --- a/tests/unit/module_utils/retries/test_awsretry.py +++ b/tests/unit/module_utils/retries/test_awsretry.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - try: import botocore except ImportError: @@ -21,7 +18,7 @@ pytestmark = pytest.mark.skip("test_awsretry.py requires the python modules 'boto3' and 'botocore'") -class TestAWSRetry(): +class TestAWSRetry: def test_no_failures(self): self.counter = 0 diff --git a/tests/unit/module_utils/retries/test_botocore_exception_maybe.py b/tests/unit/module_utils/retries/test_botocore_exception_maybe.py index 121f308b705..1adebb17c9f 100644 --- a/tests/unit/module_utils/retries/test_botocore_exception_maybe.py +++ b/tests/unit/module_utils/retries/test_botocore_exception_maybe.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - try: import botocore except ImportError: diff --git a/tests/unit/module_utils/retries/test_retry_wrapper.py b/tests/unit/module_utils/retries/test_retry_wrapper.py index bfb6a4320ed..ac3db329751 100644 --- a/tests/unit/module_utils/retries/test_retry_wrapper.py +++ b/tests/unit/module_utils/retries/test_retry_wrapper.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import call from unittest.mock import sentinel diff --git a/tests/unit/module_utils/test_elbv2.py b/tests/unit/module_utils/test_elbv2.py index 48c32c78ec7..5780d8146f4 100644 --- a/tests/unit/module_utils/test_elbv2.py +++ b/tests/unit/module_utils/test_elbv2.py @@ -4,11 +4,9 @@ # This file is part of Ansible # 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) -__metaclass__ = type +from unittest.mock import MagicMock from ansible_collections.amazon.aws.plugins.module_utils import elbv2 -from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock one_action = [ { @@ -50,7 +48,7 @@ def _sort_actions_one_entry(): assert elbv2._sort_actions(one_action) == one_action -class TestElBV2Utils(): +class TestElBV2Utils: def setup_method(self): self.connection = MagicMock(name="connection") diff --git a/tests/unit/module_utils/test_iam.py b/tests/unit/module_utils/test_iam.py index ef50b3b13aa..035ea720eaa 100644 --- a/tests/unit/module_utils/test_iam.py +++ b/tests/unit/module_utils/test_iam.py @@ -4,10 +4,8 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest +from unittest.mock import MagicMock try: import botocore @@ -15,8 +13,6 @@ # Handled by HAS_BOTO3 pass -from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock - import ansible_collections.amazon.aws.plugins.module_utils.iam as utils_iam from ansible_collections.amazon.aws.plugins.module_utils.ec2 import HAS_BOTO3 @@ -24,7 +20,7 @@ pytestmark = pytest.mark.skip("test_iam.py requires the python modules 'boto3' and 'botocore'") -class TestIamUtils(): +class TestIamUtils: def _make_denied_exception(self, partition): return botocore.exceptions.ClientError( diff --git a/tests/unit/module_utils/test_rds.py b/tests/unit/module_utils/test_rds.py index 9d96d44a8d3..6d928b73831 100644 --- a/tests/unit/module_utils/test_rds.py +++ b/tests/unit/module_utils/test_rds.py @@ -3,11 +3,9 @@ # This file is part of Ansible # 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 -__metaclass__ = type - import sys import pytest +from unittest.mock import MagicMock if sys.version_info < (3, 7): pytest.skip("contextlib.nullcontext was introduced in Python 3.7", allow_module_level=True) @@ -20,8 +18,6 @@ # Handled by HAS_BOTO3 pass -from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock - from ansible_collections.amazon.aws.plugins.module_utils import rds from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 @@ -727,7 +723,7 @@ def test__handle_errors_failed(method_name, exception, expected, error): module.fail_json_aws.call_args[1]["msg"] == expected -class TestRdsUtils(): +class TestRdsUtils: # ======================================================== # Setup some initial data that we can use within our tests diff --git a/tests/unit/module_utils/test_s3.py b/tests/unit/module_utils/test_s3.py index 8434fa932f4..519a089bc6e 100644 --- a/tests/unit/module_utils/test_s3.py +++ b/tests/unit/module_utils/test_s3.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest import random import string @@ -232,7 +229,7 @@ def test_validate_bucket_name(bucket_name, result): mod_urlparse = "ansible_collections.amazon.aws.plugins.module_utils.s3.urlparse" -class UrlInfo(object): +class UrlInfo: def __init__(self, scheme=None, hostname=None, port=None): self.hostname = hostname diff --git a/tests/unit/module_utils/test_tagging.py b/tests/unit/module_utils/test_tagging.py index 7dcf590c37a..6d74e542d28 100644 --- a/tests/unit/module_utils/test_tagging.py +++ b/tests/unit/module_utils/test_tagging.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list @@ -14,7 +11,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -class TestTagging(): +class TestTagging: # ======================================================== # Setup some initial data that we can use within our tests diff --git a/tests/unit/module_utils/test_tower.py b/tests/unit/module_utils/test_tower.py index 9e1d9021311..4f0aa26c94e 100644 --- a/tests/unit/module_utils/test_tower.py +++ b/tests/unit/module_utils/test_tower.py @@ -3,11 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - -# import pytest - import ansible_collections.amazon.aws.plugins.module_utils.tower as utils_tower WINDOWS_DOWNLOAD = "Invoke-Expression ((New-Object System.Net.Webclient).DownloadString(" \ diff --git a/tests/unit/module_utils/transformation/__init__.py b/tests/unit/module_utils/transformation/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/module_utils/transformation/test_ansible_dict_to_boto3_filter_list.py b/tests/unit/module_utils/transformation/test_ansible_dict_to_boto3_filter_list.py index 23c82b173b2..44c7785e7d3 100644 --- a/tests/unit/module_utils/transformation/test_ansible_dict_to_boto3_filter_list.py +++ b/tests/unit/module_utils/transformation/test_ansible_dict_to_boto3_filter_list.py @@ -3,14 +3,10 @@ # This file is part of Ansible # 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) - -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -class TestAnsibleDictToBoto3FilterList(): +class TestAnsibleDictToBoto3FilterList: # ======================================================== # ec2.ansible_dict_to_boto3_filter_list diff --git a/tests/unit/module_utils/transformation/test_map_complex_type.py b/tests/unit/module_utils/transformation/test_map_complex_type.py index 2300e2351dd..2c737c8a8a3 100644 --- a/tests/unit/module_utils/transformation/test_map_complex_type.py +++ b/tests/unit/module_utils/transformation/test_map_complex_type.py @@ -3,13 +3,10 @@ # This file is part of Ansible # 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) -__metaclass__ = type +from unittest.mock import sentinel from ansible_collections.amazon.aws.plugins.module_utils.transformation import map_complex_type -from ansible_collections.amazon.aws.tests.unit.compat.mock import sentinel - def test_map_complex_type_over_dict(): type_map = {'minimum_healthy_percent': 'int', 'maximum_percent': 'int'} diff --git a/tests/unit/module_utils/transformation/test_scrub_none_parameters.py b/tests/unit/module_utils/transformation/test_scrub_none_parameters.py index 82fd41ed364..7f6be7e0ffd 100644 --- a/tests/unit/module_utils/transformation/test_scrub_none_parameters.py +++ b/tests/unit/module_utils/transformation/test_scrub_none_parameters.py @@ -1,6 +1,3 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import pytest from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters diff --git a/tests/unit/plugin_utils/__init__.py b/tests/unit/plugin_utils/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugin_utils/base/__init__.py b/tests/unit/plugin_utils/base/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugin_utils/base/test_plugin.py b/tests/unit/plugin_utils/base/test_plugin.py index 594d5c495f1..f168cb4deff 100644 --- a/tests/unit/plugin_utils/base/test_plugin.py +++ b/tests/unit/plugin_utils/base/test_plugin.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import call from unittest.mock import MagicMock diff --git a/tests/unit/plugin_utils/botocore/__init__.py b/tests/unit/plugin_utils/botocore/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py b/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py index 62558318f5b..18b9d12bcf3 100644 --- a/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py +++ b/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - try: import botocore except ImportError: diff --git a/tests/unit/plugin_utils/botocore/test_get_aws_region.py b/tests/unit/plugin_utils/botocore/test_get_aws_region.py index b6f518a78e0..e3d1c9a0ef7 100644 --- a/tests/unit/plugin_utils/botocore/test_get_aws_region.py +++ b/tests/unit/plugin_utils/botocore/test_get_aws_region.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import MagicMock from unittest.mock import sentinel diff --git a/tests/unit/plugin_utils/botocore/test_get_connection_info.py b/tests/unit/plugin_utils/botocore/test_get_connection_info.py index fb552eaeba6..4304cb9d91d 100644 --- a/tests/unit/plugin_utils/botocore/test_get_connection_info.py +++ b/tests/unit/plugin_utils/botocore/test_get_connection_info.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import MagicMock from unittest.mock import sentinel diff --git a/tests/unit/plugin_utils/lookup/__init__.py b/tests/unit/plugin_utils/lookup/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugin_utils/lookup/test_lookup_base.py b/tests/unit/plugin_utils/lookup/test_lookup_base.py index 3e59943fbc5..f5ea4aff63c 100644 --- a/tests/unit/plugin_utils/lookup/test_lookup_base.py +++ b/tests/unit/plugin_utils/lookup/test_lookup_base.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import call from unittest.mock import MagicMock diff --git a/tests/unit/plugins/__init__.py b/tests/unit/plugins/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/inventory/__init__.py b/tests/unit/plugins/inventory/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/inventory/test_aws_ec2.py b/tests/unit/plugins/inventory/test_aws_ec2.py index 5386fe6c7e3..413a8358d12 100644 --- a/tests/unit/plugins/inventory/test_aws_ec2.py +++ b/tests/unit/plugins/inventory/test_aws_ec2.py @@ -17,10 +17,6 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import pytest import datetime from unittest.mock import Mock, MagicMock diff --git a/tests/unit/plugins/modules/__init__.py b/tests/unit/plugins/modules/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/modules/conftest.py b/tests/unit/plugins/modules/conftest.py index a7d1e0475f2..3bbfe0b7a85 100644 --- a/tests/unit/plugins/modules/conftest.py +++ b/tests/unit/plugins/modules/conftest.py @@ -1,9 +1,6 @@ # Copyright (c) 2017 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) -__metaclass__ = type - import json import pytest diff --git a/tests/unit/plugins/modules/ec2_eip/__init__.py b/tests/unit/plugins/modules/ec2_eip/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/modules/ec2_instance/__init__.py b/tests/unit/plugins/modules/ec2_instance/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py b/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py index e889b676a76..5000587546b 100644 --- a/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py +++ b/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py @@ -3,12 +3,9 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest +from unittest.mock import sentinel -from ansible_collections.amazon.aws.tests.unit.compat.mock import sentinel import ansible_collections.amazon.aws.plugins.modules.ec2_instance as ec2_instance_module diff --git a/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py b/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py index bdddc9f49ee..2c49f8f814c 100644 --- a/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py +++ b/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py @@ -3,14 +3,11 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest import sys +from unittest.mock import MagicMock +from unittest.mock import sentinel -from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock -from ansible_collections.amazon.aws.tests.unit.compat.mock import sentinel import ansible_collections.amazon.aws.plugins.modules.ec2_instance as ec2_instance_module import ansible_collections.amazon.aws.plugins.module_utils.arn as utils_arn from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 diff --git a/tests/unit/plugins/modules/ec2_security_group/__init__.py b/tests/unit/plugins/modules/ec2_security_group/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py b/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py index 950467fff0d..04900e14fb9 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from copy import deepcopy import pytest from unittest.mock import sentinel diff --git a/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py b/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py index d7cef80dd5e..1bcb8b12724 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import MagicMock from unittest.mock import sentinel diff --git a/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py b/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py index bee002a0256..fbd1b9526ab 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py @@ -3,9 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - from copy import deepcopy import pytest diff --git a/tests/unit/plugins/modules/fixtures/__init__.py b/tests/unit/plugins/modules/fixtures/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/modules/fixtures/certs/__init__.py b/tests/unit/plugins/modules/fixtures/certs/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/plugins/modules/test_cloudformation.py b/tests/unit/plugins/modules/test_cloudformation.py index b1756d535ee..7a5c518a659 100644 --- a/tests/unit/plugins/modules/test_cloudformation.py +++ b/tests/unit/plugins/modules/test_cloudformation.py @@ -3,10 +3,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest # Magic... @@ -61,7 +57,7 @@ default_events_limit = 10 -class FakeModule(object): +class FakeModule: def __init__(self, **kwargs): self.params = kwargs diff --git a/tests/unit/plugins/modules/test_ec2_security_group.py b/tests/unit/plugins/modules/test_ec2_security_group.py index c75dcac816a..6507ea39dbe 100644 --- a/tests/unit/plugins/modules/test_ec2_security_group.py +++ b/tests/unit/plugins/modules/test_ec2_security_group.py @@ -1,7 +1,3 @@ -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - from ansible_collections.amazon.aws.plugins.modules import ec2_security_group as group_module diff --git a/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py b/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py index 73726590f27..8b4f12c922c 100644 --- a/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py +++ b/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py @@ -3,12 +3,10 @@ # This file is part of Ansible # 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) -__metaclass__ = type +from unittest.mock import patch # Magic... Incorrectly identified by pylint as unused from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify # pylint: disable=unused-import -from ansible_collections.amazon.aws.tests.unit.compat.mock import patch from ansible_collections.amazon.aws.plugins.modules import ec2_vpc_dhcp_option as dhcp_module from ansible_collections.amazon.aws.tests.unit.plugins.modules.utils import ModuleTestCase @@ -40,7 +38,7 @@ } -class FakeModule(object): +class FakeModule: def __init__(self, **kwargs): self.params = kwargs diff --git a/tests/unit/plugins/modules/test_lambda_layer.py b/tests/unit/plugins/modules/test_lambda_layer.py index 451a61766ec..7a5250a2946 100644 --- a/tests/unit/plugins/modules/test_lambda_layer.py +++ b/tests/unit/plugins/modules/test_lambda_layer.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from unittest.mock import MagicMock, call, patch diff --git a/tests/unit/plugins/modules/test_lambda_layer_info.py b/tests/unit/plugins/modules/test_lambda_layer_info.py index 25a1f15ac36..17a6386d186 100644 --- a/tests/unit/plugins/modules/test_lambda_layer_info.py +++ b/tests/unit/plugins/modules/test_lambda_layer_info.py @@ -4,9 +4,6 @@ # This file is part of Ansible # 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) -__metaclass__ = type - import pytest from botocore.exceptions import BotoCoreError diff --git a/tests/unit/plugins/modules/utils.py b/tests/unit/plugins/modules/utils.py index 058a5b6057b..057dcd1aaf5 100644 --- a/tests/unit/plugins/modules/utils.py +++ b/tests/unit/plugins/modules/utils.py @@ -1,10 +1,7 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - import json +import unittest +from unittest.mock import patch -from ansible_collections.amazon.aws.tests.unit.compat import unittest -from ansible_collections.amazon.aws.tests.unit.compat.mock import patch from ansible.module_utils import basic from ansible.module_utils._text import to_bytes diff --git a/tests/unit/utils/__init__.py b/tests/unit/utils/__init__.py new file mode 100644 index 00000000000..e69de29bb2d