Skip to content

Commit

Permalink
isort fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GomathiselviS committed Nov 9, 2023
1 parent d2c05f0 commit f54e814
Show file tree
Hide file tree
Showing 61 changed files with 173 additions and 228 deletions.
13 changes: 6 additions & 7 deletions plugins/action/k8s_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
__metaclass__ = type

import copy
import traceback
import os
from contextlib import contextmanager
import platform
import traceback
from contextlib import contextmanager

from ansible.config.manager import ensure_type
from ansible.errors import (
AnsibleError,
AnsibleFileNotFound,
AnsibleAction,
AnsibleActionFail,
AnsibleError,
AnsibleFileNotFound,
)
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.six import string_types, iteritems
from ansible.module_utils._text import to_text, to_bytes, to_native
from ansible.module_utils.six import iteritems, string_types
from ansible.plugins.action import ActionBase


Expand Down Expand Up @@ -55,7 +55,6 @@ def output(self):


class ActionModule(ActionBase):

TRANSFERS_FILES = True
DEFAULT_NEWLINE_SEQUENCE = "\n"

Expand Down
8 changes: 4 additions & 4 deletions plugins/connection/kubectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@
aliases: [ kubectl_verify_ssl ]
"""

import json
import os
import os.path
import shutil
import subprocess
import tempfile
import json

from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils.six.moves import shlex_quote
from ansible.module_utils._text import to_bytes
from ansible.plugins.connection import ConnectionBase, BUFSIZE
from ansible.module_utils.six.moves import shlex_quote
from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.plugins.connection import BUFSIZE, ConnectionBase
from ansible.utils.display import Display

display = Display()
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/helm_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
binary_path:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_auth_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
host:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_delete_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
delete_options:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_name_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
api_version:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_resource_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
resource_definition:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_scale_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
replicas:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_state_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
state:
Expand Down
1 change: 0 additions & 1 deletion plugins/doc_fragments/k8s_wait_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ModuleDocFragment(object):

DOCUMENTATION = r"""
options:
wait:
Expand Down
3 changes: 1 addition & 2 deletions plugins/inventory/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@
import json

from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, Constructable
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
HAS_K8S_MODULE_HELPER,
k8s_import_exception,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable

try:
from kubernetes.dynamic.exceptions import DynamicApiError
Expand Down Expand Up @@ -193,7 +193,6 @@ def setup(self, config_data, cache, cache_key):
self.fetch_objects(connections)

def fetch_objects(self, connections):

if connections:
if not isinstance(connections, list):
raise K8sInventoryException("Expecting connections to be a list.")
Expand Down
2 changes: 0 additions & 2 deletions plugins/lookup/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@
from ansible.errors import AnsibleError
from ansible.module_utils.common._collections_compat import KeysView
from ansible.module_utils.common.validation import check_type_bool

from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
Expand Down Expand Up @@ -214,7 +213,6 @@

class KubernetesLookup(object):
def __init__(self):

if not HAS_K8S_MODULE_HELPER:
raise Exception(
"Requires the Kubernetes Python client. Try `pip install kubernetes`. Detail: {0}".format(
Expand Down
7 changes: 3 additions & 4 deletions plugins/lookup/kustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@
key1: val1
"""

import subprocess

from ansible.errors import AnsibleLookupError
from ansible.plugins.lookup import LookupBase
from ansible.module_utils.common.process import get_bin_path


import subprocess
from ansible.plugins.lookup import LookupBase


def get_binary_from_path(name, opt_dirs=None):
Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/ansiblemodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

if enable_turbo_mode:
try:
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import (
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import ( # noqa: F401
AnsibleTurboModule as AnsibleModule,
) # noqa: F401
)

AnsibleModule.collection_name = "kubernetes.core"
except ImportError:
Expand Down
3 changes: 1 addition & 2 deletions plugins/module_utils/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

__metaclass__ = type

from collections import OrderedDict
import json
from collections import OrderedDict

from ansible.module_utils.common.dict_transformations import dict_merge
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
Expand All @@ -31,7 +31,6 @@
LooseVersion,
)


try:
from kubernetes.dynamic.exceptions import NotFoundError
except ImportError:
Expand Down
11 changes: 5 additions & 6 deletions plugins/module_utils/client/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@
# limitations under the License.


import hashlib
import json
import os
from collections import defaultdict
import hashlib
import tempfile
from collections import defaultdict
from functools import partial

import kubernetes.dynamic
import kubernetes.dynamic.discovery
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
ResourceList,
)
from kubernetes import __version__
from kubernetes.dynamic.exceptions import (
ResourceNotFoundError,
ResourceNotUniqueError,
ServiceUnavailableError,
)

from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
ResourceList,
)


class Discoverer(kubernetes.dynamic.discovery.Discoverer):
def __init__(self, client, cache_file):
Expand Down
41 changes: 20 additions & 21 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@
__metaclass__ = type

import base64
import time
import hashlib
import os
import traceback
import sys
import hashlib
import time
import traceback
from datetime import datetime
from tempfile import NamedTemporaryFile

from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion,
)
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.common.dict_transformations import dict_merge
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils.urls import Request
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_MAP,
AUTH_ARG_SPEC,
Expand All @@ -42,27 +45,23 @@
from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
LabelSelectorFilter,
)

from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils._text import to_native, to_bytes, to_text
from ansible.module_utils.common.dict_transformations import dict_merge
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.urls import Request
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion,
)

K8S_IMP_ERR = None
try:
import kubernetes
from kubernetes.dynamic.exceptions import (
NotFoundError,
ResourceNotFoundError,
ResourceNotUniqueError,
DynamicApiError,
BadRequestError,
ConflictError,
DynamicApiError,
ForbiddenError,
MethodNotAllowedError,
BadRequestError,
KubernetesValidateMissing,
MethodNotAllowedError,
NotFoundError,
ResourceNotFoundError,
ResourceNotUniqueError,
)

HAS_K8S_MODULE_HELPER = True
Expand Down Expand Up @@ -819,7 +818,7 @@ def execute_module(self):
try:
self.client = get_api_client(self.module)
# Hopefully the kubernetes client will provide its own exception class one day
except (urllib3.exceptions.RequestError) as e:
except urllib3.exceptions.RequestError as e:
self.fail_json(msg="Couldn't connect to Kubernetes: %s" % str(e))

flattened_definitions = []
Expand All @@ -837,7 +836,7 @@ def execute_module(self):
resource = self.find_resource(kind, api_version, fail=True)
flattened_definitions.append((resource, definition))

for (resource, definition) in flattened_definitions:
for resource, definition in flattened_definitions:
kind = definition.get("kind", self.kind)
api_version = definition.get("apiVersion", self.api_version)
definition = self.set_defaults(resource, definition)
Expand Down
15 changes: 8 additions & 7 deletions plugins/module_utils/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@
__metaclass__ = type

import os
from tempfile import TemporaryFile, NamedTemporaryFile
from select import select
from abc import ABCMeta, abstractmethod
import tarfile
from abc import ABCMeta, abstractmethod
from select import select
from tempfile import NamedTemporaryFile, TemporaryFile

from ansible.module_utils._text import to_native

# from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException,
)
from ansible.module_utils._text import to_native

try:
from kubernetes.client.api import core_v1_api
from kubernetes.stream import stream
from kubernetes.stream.ws_client import (
STDOUT_CHANNEL,
STDERR_CHANNEL,
ERROR_CHANNEL,
ABNF,
ERROR_CHANNEL,
STDERR_CHANNEL,
STDOUT_CHANNEL,
)
except ImportError:
pass
Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

__metaclass__ = type

import json
import hashlib
import json

try:
import string
Expand All @@ -37,7 +37,7 @@

def sorted_dict(unsorted_dict):
result = OrderedDict()
for (k, v) in sorted(unsorted_dict.items()):
for k, v in sorted(unsorted_dict.items()):
if isinstance(v, dict):
v = sorted_dict(v)
result[k] = v
Expand Down
Loading

0 comments on commit f54e814

Please sign in to comment.