diff --git a/salt/modules/libcloud_compute.py b/salt/modules/libcloud_compute.py index 64a1df7c4e6..b3ad97f0387 100644 --- a/salt/modules/libcloud_compute.py +++ b/salt/modules/libcloud_compute.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Apache Libcloud Compute Management ================================== @@ -30,21 +29,16 @@ Clouds include Amazon EC2, Azure, Google GCE, VMware, OpenStack Nova # keep lint from choking on _get_conn and _cache_id # pylint: disable=E0602 -from __future__ import absolute_import, print_function, unicode_literals -# Import Python libs import logging import os.path -# Import salt libs import salt.utils.args import salt.utils.compat -from salt.ext import six from salt.utils.versions import LooseVersion as _LooseVersion log = logging.getLogger(__name__) -# Import third party libs REQUIRED_LIBCLOUD_VERSION = "2.0.0" try: # pylint: disable=unused-import @@ -69,7 +63,7 @@ def __virtual__(): """ if not HAS_LIBCLOUD: msg = ( - "A apache-libcloud library with version at least {0} was not " "found" + "A apache-libcloud library with version at least {} was not " "found" ).format(REQUIRED_LIBCLOUD_VERSION) return (False, msg) return True @@ -790,7 +784,7 @@ def _get_by_id(collection, id): if not matches: raise ValueError("Could not find a matching item") elif len(matches) > 1: - raise ValueError("The id matched {0} items, not 1".format(len(matches))) + raise ValueError("The id matched {} items, not 1".format(len(matches))) return matches[0] @@ -824,7 +818,7 @@ def _simple_node(node): return { "id": node.id, "name": node.name, - "state": six.text_type(node.state), + "state": str(node.state), "public_ips": node.public_ips, "private_ips": node.private_ips, "size": _simple_size(node.size) if node.size else {}, diff --git a/salt/modules/libcloud_dns.py b/salt/modules/libcloud_dns.py index f0355c3c348..86107ef9982 100644 --- a/salt/modules/libcloud_dns.py +++ b/salt/modules/libcloud_dns.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Apache Libcloud DNS Management ============================== @@ -28,17 +27,13 @@ Connection module for Apache Libcloud DNS management # keep lint from choking on _get_conn and _cache_id # pylint: disable=E0602 -from __future__ import absolute_import, print_function, unicode_literals -# Import Python libs import logging -# Import salt libs from salt.utils.versions import LooseVersion as _LooseVersion log = logging.getLogger(__name__) -# Import third party libs REQUIRED_LIBCLOUD_VERSION = "2.0.0" try: # pylint: disable=unused-import @@ -63,7 +58,7 @@ def __virtual__(): """ if not HAS_LIBCLOUD: msg = ( - "A apache-libcloud library with version at least {0} was not " "found" + "A apache-libcloud library with version at least {} was not " "found" ).format(REQUIRED_LIBCLOUD_VERSION) return (False, msg) return True diff --git a/salt/modules/libcloud_loadbalancer.py b/salt/modules/libcloud_loadbalancer.py index 93347247db2..5a93706b6aa 100644 --- a/salt/modules/libcloud_loadbalancer.py +++ b/salt/modules/libcloud_loadbalancer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Apache Libcloud Load Balancer Management ======================================== @@ -30,20 +29,15 @@ Clouds include Amazon ELB, ALB, Google, Aliyun, CloudStack, Softlayer # keep lint from choking on _get_conn and _cache_id # pylint: disable=E0602 -from __future__ import absolute_import, print_function, unicode_literals -# Import Python libs import logging -# Import salt libs import salt.utils.args import salt.utils.compat -from salt.ext import six from salt.utils.versions import LooseVersion as _LooseVersion log = logging.getLogger(__name__) -# Import third party libs REQUIRED_LIBCLOUD_VERSION = "1.5.0" try: # pylint: disable=unused-import @@ -68,7 +62,7 @@ def __virtual__(): """ if not HAS_LIBCLOUD: msg = ( - "A apache-libcloud library with version at least {0} was not " "found" + "A apache-libcloud library with version at least {} was not " "found" ).format(REQUIRED_LIBCLOUD_VERSION) return (False, msg) return True @@ -186,7 +180,7 @@ def create_balancer( if algorithm is None: algorithm = Algorithm.ROUND_ROBIN else: - if isinstance(algorithm, six.string_types): + if isinstance(algorithm, str): algorithm = _algorithm_maps()[algorithm] starting_members = [] if members is not None: diff --git a/salt/modules/libcloud_storage.py b/salt/modules/libcloud_storage.py index cab9fc28ce1..d1ff680eabd 100644 --- a/salt/modules/libcloud_storage.py +++ b/salt/modules/libcloud_storage.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Apache Libcloud Storage Management ================================== @@ -30,19 +29,15 @@ Clouds include Amazon S3, Google Storage, Aliyun, Azure Blobs, Ceph, OpenStack s # keep lint from choking on _get_conn and _cache_id # pylint: disable=E0602 -from __future__ import absolute_import, print_function, unicode_literals -# Import Python libs import logging -# Import salt libs import salt.utils.args import salt.utils.compat from salt.utils.versions import LooseVersion as _LooseVersion log = logging.getLogger(__name__) -# Import third party libs REQUIRED_LIBCLOUD_VERSION = "1.5.0" try: # pylint: disable=unused-import @@ -66,7 +61,7 @@ def __virtual__(): """ if not HAS_LIBCLOUD: msg = ( - "A apache-libcloud library with version at least {0} was not " "found" + "A apache-libcloud library with version at least {} was not " "found" ).format(REQUIRED_LIBCLOUD_VERSION) return (False, msg) return True diff --git a/salt/states/libcloud_dns.py b/salt/states/libcloud_dns.py index 7e1fdef9ef9..a78a5d17dde 100644 --- a/salt/states/libcloud_dns.py +++ b/salt/states/libcloud_dns.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Manage DNS records and zones using libcloud @@ -47,9 +46,6 @@ Example: :depends: apache-libcloud """ -# Import Python Libs -from __future__ import absolute_import - def __virtual__(): if "libcloud_dns.list_zones" in __salt__: @@ -189,8 +185,6 @@ def record_absent(name, zone, type, data, profile): matching_zone["id"], record["id"], profile ) ) - return state_result( - all(result), "Removed {0} records".format(len(result)), name - ) + return state_result(all(result), "Removed {} records".format(len(result)), name) else: return state_result(True, "Records already absent", name) diff --git a/salt/states/libcloud_loadbalancer.py b/salt/states/libcloud_loadbalancer.py index 68daecb5f5e..c49ea093c1f 100644 --- a/salt/states/libcloud_loadbalancer.py +++ b/salt/states/libcloud_loadbalancer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Apache Libcloud Load Balancer State =================================== @@ -46,8 +45,6 @@ Using States to deploy a load balancer with extended arguments to specify region :depends: apache-libcloud """ -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals import logging @@ -161,7 +158,7 @@ def member_present(ip, port, balancer_id, profile, **libcloud_kwargs): ) return state_result( True, - "Member added to balancer, id: {0}".format(member["id"]), + "Member added to balancer, id: {}".format(member["id"]), balancer_id, member, ) diff --git a/salt/states/libcloud_storage.py b/salt/states/libcloud_storage.py index d888169ca1d..b8b7aaae348 100644 --- a/salt/states/libcloud_storage.py +++ b/salt/states/libcloud_storage.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Apache Libcloud Storage State ============================= @@ -64,8 +63,6 @@ This example will download the file from the remote cloud and keep it locally :depends: apache-libcloud """ -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals import logging diff --git a/templates/module/salt/modules/{{module_name}}.py b/templates/module/salt/modules/{{module_name}}.py index d5e0444bcf1..2d22bf9f867 100644 --- a/templates/module/salt/modules/{{module_name}}.py +++ b/templates/module/salt/modules/{{module_name}}.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ''' {{module_name}} execution module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -13,14 +12,10 @@ ''' -# Import Python libs -from __future__ import absolute_import, unicode_literals, print_function import logging -# Import salt libs import salt.utils.compat -# Import third party libs try: # Import libs... {% if depending_libraries %} diff --git a/templates/state/salt/states/{{module_name}}.py b/templates/state/salt/states/{{module_name}}.py index b1021b51dba..692f82aef66 100644 --- a/templates/state/salt/states/{{module_name}}.py +++ b/templates/state/salt/states/{{module_name}}.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ''' {{module_name}} state module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -14,14 +13,10 @@ ''' -# Import Python libs -from __future__ import absolute_import, unicode_literals, print_function import logging -# Import salt libs import salt.utils.compat -# Import third party libs try: # Import libs... {% if depending_libraries %} diff --git a/tests/unit/modules/test_libcloud_compute.py b/tests/unit/modules/test_libcloud_compute.py index 8285b73d1c8..57c2bd4c8c1 100644 --- a/tests/unit/modules/test_libcloud_compute.py +++ b/tests/unit/modules/test_libcloud_compute.py @@ -1,17 +1,12 @@ -# -*- coding: utf-8 -*- """ :codeauthor: :email:`Anthony Shaw ` """ -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals import logging import salt.modules.libcloud_compute as libcloud_compute from salt.utils.versions import LooseVersion as _LooseVersion - -# Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock, patch from tests.support.unit import TestCase, skipIf diff --git a/tests/unit/modules/test_libcloud_dns.py b/tests/unit/modules/test_libcloud_dns.py index 0a5ed336f6d..5800b099b90 100644 --- a/tests/unit/modules/test_libcloud_dns.py +++ b/tests/unit/modules/test_libcloud_dns.py @@ -1,20 +1,15 @@ -# -*- coding: utf-8 -*- """ :codeauthor: Anthony Shaw """ -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals import salt.modules.libcloud_dns as libcloud_dns - -# Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock from tests.support.unit import TestCase, skipIf -class MockDNSDriver(object): +class MockDNSDriver: def __init__(self): pass diff --git a/tests/unit/modules/test_libcloud_loadbalancer.py b/tests/unit/modules/test_libcloud_loadbalancer.py index 7f94b511a65..c04ee07a282 100644 --- a/tests/unit/modules/test_libcloud_loadbalancer.py +++ b/tests/unit/modules/test_libcloud_loadbalancer.py @@ -1,14 +1,9 @@ -# -*- coding: utf-8 -*- """ :codeauthor: :email:`Anthony Shaw ` """ -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals import salt.modules.libcloud_loadbalancer as libcloud_loadbalancer - -# Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock, patch from tests.support.unit import TestCase, skipIf diff --git a/tests/unit/modules/test_libcloud_storage.py b/tests/unit/modules/test_libcloud_storage.py index cf4194c231b..44058c00c48 100644 --- a/tests/unit/modules/test_libcloud_storage.py +++ b/tests/unit/modules/test_libcloud_storage.py @@ -1,14 +1,9 @@ -# -*- coding: utf-8 -*- """ :codeauthor: :email:`Anthony Shaw ` """ -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals import salt.modules.libcloud_storage as libcloud_storage - -# Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock, patch from tests.support.unit import TestCase, skipIf