Skip to content

Commit

Permalink
Mass remove Python 2.x compatibility code (ansible-collections#1257)
Browse files Browse the repository at this point in the history
Mass remove Python 2.x compatibility code

Depends-On: ansible-collections#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 <None>
Reviewed-by: Gonéri Le Bouder <[email protected]>
  • Loading branch information
tremble authored Nov 10, 2022
1 parent 3d071cb commit 680cfc8
Show file tree
Hide file tree
Showing 218 changed files with 64 additions and 1,288 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1257-python2-compat.yml
Original file line number Diff line number Diff line change
@@ -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).
4 changes: 1 addition & 3 deletions plugins/action/s3_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os

Expand All @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions plugins/callback/aws_resource_actions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'):
Expand Down
5 changes: 1 addition & 4 deletions plugins/doc_fragments/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand All @@ -15,6 +12,6 @@
#


class ModuleDocFragment(object):
class ModuleDocFragment:
def __init__(self):
self.DOCUMENTATION = CommonFragment.MODULES
6 changes: 1 addition & 5 deletions plugins/doc_fragments/aws_credentials.py
Original file line number Diff line number Diff line change
@@ -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"""
Expand Down
6 changes: 1 addition & 5 deletions plugins/doc_fragments/aws_region.py
Original file line number Diff line number Diff line change
@@ -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

#
Expand All @@ -16,6 +12,6 @@
#


class ModuleDocFragment(object):
class ModuleDocFragment:
def __init__(self):
self.DOCUMENTATION = RegionFragment.PLUGINS
6 changes: 1 addition & 5 deletions plugins/doc_fragments/boto3.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
7 changes: 1 addition & 6 deletions plugins/doc_fragments/common.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2014, Will Thames <[email protected]>
# 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.

Expand Down
6 changes: 1 addition & 5 deletions plugins/doc_fragments/ec2.py
Original file line number Diff line number Diff line change
@@ -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

#
Expand All @@ -16,6 +12,6 @@
#


class ModuleDocFragment(object):
class ModuleDocFragment:
def __init__(self):
self.DOCUMENTATION = RegionFragment.MODULES
6 changes: 1 addition & 5 deletions plugins/doc_fragments/region.py
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
6 changes: 1 addition & 5 deletions plugins/doc_fragments/tags.py
Original file line number Diff line number Diff line change
@@ -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"""
Expand Down
3 changes: 0 additions & 3 deletions plugins/inventory/aws_ec2.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions plugins/inventory/aws_rds.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions plugins/lookup/aws_account_attribute.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 0 additions & 2 deletions plugins/lookup/aws_service_ip_ranges.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# (c) 2016 James Turner <[email protected]>
# (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
Expand Down
5 changes: 1 addition & 4 deletions plugins/lookup/secretsmanager_secret.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Copyright: (c) 2018, Aaron Smith <[email protected]>
# 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:
Expand Down Expand Up @@ -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')
Expand Down
5 changes: 1 addition & 4 deletions plugins/lookup/ssm_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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')
Expand Down
5 changes: 1 addition & 4 deletions plugins/module_utils/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/arn.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import re


Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/botocore.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
connections.
"""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import json
import os
import traceback
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions plugins/module_utils/cloudfront_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/direct_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/elb_utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading

0 comments on commit 680cfc8

Please sign in to comment.