diff --git a/changelogs/fragments/remove-unneeded-imports.yml b/changelogs/fragments/remove-unneeded-imports.yml new file mode 100644 index 0000000000..a5fed1d93e --- /dev/null +++ b/changelogs/fragments/remove-unneeded-imports.yml @@ -0,0 +1,2 @@ +bugfixes: + - "various plugins and modules - remove unnecessary imports (https://github.com/ansible-collections/community.general/pull/5940)." diff --git a/plugins/cache/memcached.py b/plugins/cache/memcached.py index 77f1717e45..0bc5256b3f 100644 --- a/plugins/cache/memcached.py +++ b/plugins/cache/memcached.py @@ -52,11 +52,9 @@ import time from multiprocessing import Lock from itertools import chain -from ansible import constants as C from ansible.errors import AnsibleError from ansible.module_utils.common._collections_compat import MutableSet from ansible.plugins.cache import BaseCacheModule -from ansible.release import __version__ as ansible_base_version from ansible.utils.display import Display try: diff --git a/plugins/cache/redis.py b/plugins/cache/redis.py index 81e960cf18..8c06217176 100644 --- a/plugins/cache/redis.py +++ b/plugins/cache/redis.py @@ -67,12 +67,10 @@ import re import time import json -from ansible import constants as C from ansible.errors import AnsibleError from ansible.module_utils.common.text.converters import to_native from ansible.parsing.ajson import AnsibleJSONEncoder, AnsibleJSONDecoder from ansible.plugins.cache import BaseCacheModule -from ansible.release import __version__ as ansible_base_version from ansible.utils.display import Display try: diff --git a/plugins/callback/counter_enabled.py b/plugins/callback/counter_enabled.py index 555ebd29a6..27adc97a6c 100644 --- a/plugins/callback/counter_enabled.py +++ b/plugins/callback/counter_enabled.py @@ -27,7 +27,6 @@ DOCUMENTATION = ''' from ansible import constants as C from ansible.plugins.callback import CallbackBase from ansible.utils.color import colorize, hostcolor -from ansible.template import Templar from ansible.playbook.task_include import TaskInclude diff --git a/plugins/callback/diy.py b/plugins/callback/diy.py index 55a07725f2..75b3f4e24b 100644 --- a/plugins/callback/diy.py +++ b/plugins/callback/diy.py @@ -786,10 +786,6 @@ playbook.yml: > import sys from contextlib import contextmanager -from ansible import constants as C -from ansible.playbook.task_include import TaskInclude -from ansible.plugins.callback import CallbackBase -from ansible.utils.color import colorize, hostcolor from ansible.template import Templar from ansible.vars.manager import VariableManager from ansible.plugins.callback.default import CallbackModule as Default diff --git a/plugins/callback/loganalytics.py b/plugins/callback/loganalytics.py index 8690aac934..fbcdc6f89f 100644 --- a/plugins/callback/loganalytics.py +++ b/plugins/callback/loganalytics.py @@ -54,7 +54,6 @@ examples: | import hashlib import hmac import base64 -import logging import json import uuid import socket diff --git a/plugins/callback/mail.py b/plugins/callback/mail.py index a605d13eac..9e8314baf8 100644 --- a/plugins/callback/mail.py +++ b/plugins/callback/mail.py @@ -79,7 +79,6 @@ import re import email.utils import smtplib -from ansible.module_utils.six import string_types from ansible.module_utils.common.text.converters import to_bytes from ansible.parsing.ajson import AnsibleJSONEncoder from ansible.plugins.callback import CallbackBase diff --git a/plugins/callback/nrdp.py b/plugins/callback/nrdp.py index 8295bf9759..c16a3c7bec 100644 --- a/plugins/callback/nrdp.py +++ b/plugins/callback/nrdp.py @@ -67,9 +67,6 @@ DOCUMENTATION = ''' type: string ''' -import os -import json - from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.common.text.converters import to_bytes from ansible.module_utils.urls import open_url diff --git a/plugins/callback/syslog_json.py b/plugins/callback/syslog_json.py index 2bd8f6e604..0f5ec4d0d9 100644 --- a/plugins/callback/syslog_json.py +++ b/plugins/callback/syslog_json.py @@ -54,9 +54,6 @@ DOCUMENTATION = ''' version_added: 4.5.0 ''' -import os -import json - import logging import logging.handlers diff --git a/plugins/callback/yaml.py b/plugins/callback/yaml.py index 73782de151..ae2c8f8810 100644 --- a/plugins/callback/yaml.py +++ b/plugins/callback/yaml.py @@ -25,12 +25,10 @@ import yaml import json import re import string -import sys -from ansible.module_utils.common.text.converters import to_bytes, to_text -from ansible.module_utils.six import string_types +from ansible.module_utils.common.text.converters import to_text from ansible.parsing.yaml.dumper import AnsibleDumper -from ansible.plugins.callback import CallbackBase, strip_internal_keys, module_response_deepcopy +from ansible.plugins.callback import strip_internal_keys, module_response_deepcopy from ansible.plugins.callback.default import CallbackModule as Default diff --git a/plugins/filter/jc.py b/plugins/filter/jc.py index 6708f573d3..742d4147a1 100644 --- a/plugins/filter/jc.py +++ b/plugins/filter/jc.py @@ -80,13 +80,13 @@ from ansible.errors import AnsibleError, AnsibleFilterError import importlib try: - import jc + import jc # noqa: F401, pylint: disable=unused-import HAS_LIB = True except ImportError: HAS_LIB = False -def jc(data, parser, quiet=True, raw=False): +def jc_filter(data, parser, quiet=True, raw=False): """Convert returned command output to JSON using the JC library Arguments: @@ -150,5 +150,5 @@ class FilterModule(object): def filters(self): return { - 'jc': jc + 'jc': jc_filter, } diff --git a/plugins/filter/lists_mergeby.py b/plugins/filter/lists_mergeby.py index a89039ed89..036dfe4d7c 100644 --- a/plugins/filter/lists_mergeby.py +++ b/plugins/filter/lists_mergeby.py @@ -102,8 +102,6 @@ from ansible.errors import AnsibleFilterError from ansible.module_utils.six import string_types from ansible.module_utils.common._collections_compat import Mapping, Sequence from ansible.utils.vars import merge_hash -from ansible.release import __version__ as ansible_version -from ansible_collections.community.general.plugins.module_utils.version import LooseVersion from collections import defaultdict from operator import itemgetter diff --git a/plugins/inventory/linode.py b/plugins/inventory/linode.py index ea87a9a58e..b28cfa27ba 100644 --- a/plugins/inventory/linode.py +++ b/plugins/inventory/linode.py @@ -121,10 +121,7 @@ compose: ansible_host: "ipv4 | community.general.json_query('[?public==`false`].address') | first" ''' -import os - -from ansible.errors import AnsibleError, AnsibleParserError -from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable diff --git a/plugins/inventory/lxd.py b/plugins/inventory/lxd.py index 2e37de70c1..bd0a6ce008 100644 --- a/plugins/inventory/lxd.py +++ b/plugins/inventory/lxd.py @@ -150,12 +150,10 @@ groupby: attribute: internals ''' -import binascii import json import re import time import os -import socket from ansible.plugins.inventory import BaseInventoryPlugin from ansible.module_utils.common.text.converters import to_native, to_text from ansible.module_utils.common.dict_transformations import dict_merge diff --git a/plugins/inventory/online.py b/plugins/inventory/online.py index 261548d8a2..3fccd58d2f 100644 --- a/plugins/inventory/online.py +++ b/plugins/inventory/online.py @@ -65,7 +65,7 @@ from sys import version as python_version from ansible.errors import AnsibleError from ansible.module_utils.urls import open_url from ansible.plugins.inventory import BaseInventoryPlugin -from ansible.module_utils.common.text.converters import to_native, to_text +from ansible.module_utils.common.text.converters import to_text from ansible.module_utils.ansible_release import __version__ as ansible_version from ansible.module_utils.six.moves.urllib.parse import urljoin diff --git a/plugins/lookup/consul_kv.py b/plugins/lookup/consul_kv.py index 2d4a202d94..f17f1b2694 100644 --- a/plugins/lookup/consul_kv.py +++ b/plugins/lookup/consul_kv.py @@ -105,7 +105,6 @@ RETURN = """ type: dict """ -import os from ansible.module_utils.six.moves.urllib.parse import urlparse from ansible.errors import AnsibleError, AnsibleAssertionError from ansible.plugins.lookup import LookupBase diff --git a/plugins/lookup/credstash.py b/plugins/lookup/credstash.py index d49d5b23cb..6a3f58595b 100644 --- a/plugins/lookup/credstash.py +++ b/plugins/lookup/credstash.py @@ -93,8 +93,6 @@ RETURN = """ type: str """ -import os - from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase diff --git a/plugins/lookup/cyberarkpassword.py b/plugins/lookup/cyberarkpassword.py index 1e005e23e8..c3cc427df8 100644 --- a/plugins/lookup/cyberarkpassword.py +++ b/plugins/lookup/cyberarkpassword.py @@ -80,7 +80,6 @@ from subprocess import Popen from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase -from ansible.parsing.splitter import parse_kv from ansible.module_utils.common.text.converters import to_bytes, to_text, to_native from ansible.utils.display import Display diff --git a/plugins/lookup/etcd3.py b/plugins/lookup/etcd3.py index df41d791e8..7f0a0cf90e 100644 --- a/plugins/lookup/etcd3.py +++ b/plugins/lookup/etcd3.py @@ -136,12 +136,11 @@ RETURN = ''' import re -from ansible.plugins.lookup import LookupBase -from ansible.utils.display import Display +from ansible.errors import AnsibleLookupError from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.common.text.converters import to_native from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError, AnsibleLookupError +from ansible.utils.display import Display try: import etcd3 diff --git a/plugins/lookup/hiera.py b/plugins/lookup/hiera.py index 1049e80b02..fa4d0a1999 100644 --- a/plugins/lookup/hiera.py +++ b/plugins/lookup/hiera.py @@ -61,8 +61,6 @@ RETURN = """ elements: str """ -import os - from ansible.plugins.lookup import LookupBase from ansible.utils.cmd_functions import run_cmd from ansible.module_utils.common.text.converters import to_text diff --git a/plugins/lookup/manifold.py b/plugins/lookup/manifold.py index 51064b9c2b..049d453e4f 100644 --- a/plugins/lookup/manifold.py +++ b/plugins/lookup/manifold.py @@ -69,7 +69,6 @@ from ansible.utils.display import Display from traceback import format_exception import json import sys -import os display = Display() diff --git a/plugins/lookup/redis.py b/plugins/lookup/redis.py index 490751a398..43b046a798 100644 --- a/plugins/lookup/redis.py +++ b/plugins/lookup/redis.py @@ -73,8 +73,6 @@ _raw: elements: str """ -import os - HAVE_REDIS = False try: import redis diff --git a/plugins/module_utils/dimensiondata.py b/plugins/module_utils/dimensiondata.py index 308615bfe4..0300f6c1e9 100644 --- a/plugins/module_utils/dimensiondata.py +++ b/plugins/module_utils/dimensiondata.py @@ -19,15 +19,16 @@ import os import re import traceback -from ansible.module_utils.basic import AnsibleModule, missing_required_lib +# (TODO: remove AnsibleModule from next line!) +from ansible.module_utils.basic import AnsibleModule, missing_required_lib # noqa: F401, pylint: disable=unused-import from ansible.module_utils.six.moves import configparser from os.path import expanduser from uuid import UUID LIBCLOUD_IMP_ERR = None try: - from libcloud.common.dimensiondata import API_ENDPOINTS, DimensionDataAPIException, DimensionDataStatus - from libcloud.compute.base import Node, NodeLocation + from libcloud.common.dimensiondata import API_ENDPOINTS, DimensionDataAPIException, DimensionDataStatus # noqa: F401, pylint: disable=unused-import + from libcloud.compute.base import Node, NodeLocation # noqa: F401, pylint: disable=unused-import from libcloud.compute.providers import get_driver from libcloud.compute.types import Provider diff --git a/plugins/module_utils/influxdb.py b/plugins/module_utils/influxdb.py index 9a30e76428..580cabe7d5 100644 --- a/plugins/module_utils/influxdb.py +++ b/plugins/module_utils/influxdb.py @@ -15,7 +15,7 @@ from ansible_collections.community.general.plugins.module_utils.version import L REQUESTS_IMP_ERR = None try: - import requests.exceptions + import requests.exceptions # noqa: F401, pylint: disable=unused-import HAS_REQUESTS = True except ImportError: REQUESTS_IMP_ERR = traceback.format_exc() @@ -25,7 +25,7 @@ INFLUXDB_IMP_ERR = None try: from influxdb import InfluxDBClient from influxdb import __version__ as influxdb_version - from influxdb import exceptions + from influxdb import exceptions # noqa: F401, pylint: disable=unused-import HAS_INFLUXDB = True except ImportError: INFLUXDB_IMP_ERR = traceback.format_exc() diff --git a/plugins/module_utils/mh/module_helper.py b/plugins/module_utils/mh/module_helper.py index 6813b5454b..212ebb48fe 100644 --- a/plugins/module_utils/mh/module_helper.py +++ b/plugins/module_utils/mh/module_helper.py @@ -9,7 +9,8 @@ __metaclass__ = type from ansible.module_utils.common.dict_transformations import dict_merge -from ansible_collections.community.general.plugins.module_utils.mh.base import ModuleHelperBase, AnsibleModule +# (TODO: remove AnsibleModule!) pylint: disable-next-line=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.base import ModuleHelperBase, AnsibleModule # noqa: F401 from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyMixin diff --git a/plugins/module_utils/module_helper.py b/plugins/module_utils/module_helper.py index 4cda4175c7..ec7f1b1b78 100644 --- a/plugins/module_utils/module_helper.py +++ b/plugins/module_utils/module_helper.py @@ -8,12 +8,13 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ( +from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ( # noqa: F401, pylint: disable=unused-import ModuleHelper, StateModuleHelper, CmdModuleHelper, CmdStateModuleHelper, AnsibleModule ) -from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin, ArgFormat -from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin -from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyCtxMgr -from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException -from ansible_collections.community.general.plugins.module_utils.mh.deco import cause_changes, module_fails_on_exception -from ansible_collections.community.general.plugins.module_utils.mh.mixins.vars import VarMeta, VarDict +from ansible_collections.community.general.plugins.module_utils.mh.mixins.cmd import CmdMixin, ArgFormat # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.mixins.state import StateMixin # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.mixins.deps import DependencyCtxMgr # noqa: F401, pylint: disable=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException # noqa: F401, pylint: disable=unused-import +# pylint: disable-next-line=unused-import +from ansible_collections.community.general.plugins.module_utils.mh.deco import cause_changes, module_fails_on_exception # noqa: F401 +from ansible_collections.community.general.plugins.module_utils.mh.mixins.vars import VarMeta, VarDict # noqa: F401, pylint: disable=unused-import diff --git a/plugins/module_utils/oneview.py b/plugins/module_utils/oneview.py index dfd00c514e..4315a462dc 100644 --- a/plugins/module_utils/oneview.py +++ b/plugins/module_utils/oneview.py @@ -16,7 +16,8 @@ __metaclass__ = type import abc import collections import json -import os +# (TODO: remove next line!) +import os # noqa: F401, pylint: disable=unused-import import traceback HPE_ONEVIEW_IMP_ERR = None diff --git a/plugins/module_utils/oracle/oci_utils.py b/plugins/module_utils/oracle/oci_utils.py index 76fb45324b..3d9c20f2ac 100644 --- a/plugins/module_utils/oracle/oci_utils.py +++ b/plugins/module_utils/oracle/oci_utils.py @@ -10,13 +10,14 @@ import logging import logging.config import os import tempfile -from datetime import datetime +# (TODO: remove next line!) +from datetime import datetime # noqa: F401, pylint: disable=unused-import from operator import eq import time try: - import yaml + import yaml # noqa: F401, pylint: disable=unused-import import oci from oci.constants import HEADER_NEXT_PAGE diff --git a/plugins/module_utils/proxmox.py b/plugins/module_utils/proxmox.py index 96a96c8b3c..58287cec17 100644 --- a/plugins/module_utils/proxmox.py +++ b/plugins/module_utils/proxmox.py @@ -7,9 +7,12 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -import atexit -import time -import re +# (TODO: remove next line!) +import atexit # noqa: F401, pylint: disable=unused-import +# (TODO: remove next line!) +import time # noqa: F401, pylint: disable=unused-import +# (TODO: remove next line!) +import re # noqa: F401, pylint: disable=unused-import import traceback PROXMOXER_IMP_ERR = None @@ -22,7 +25,8 @@ except ImportError: from ansible.module_utils.basic import env_fallback, missing_required_lib -from ansible.module_utils.common.text.converters import to_native +# (TODO: remove next line!) +from ansible.module_utils.common.text.converters import to_native # noqa: F401, pylint: disable=unused-import from ansible_collections.community.general.plugins.module_utils.version import LooseVersion diff --git a/plugins/module_utils/pure.py b/plugins/module_utils/pure.py index c9914c38b5..8210e28f4d 100644 --- a/plugins/module_utils/pure.py +++ b/plugins/module_utils/pure.py @@ -21,13 +21,15 @@ except ImportError: HAS_PURITY_FB = True try: - from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest + from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest # noqa: F401, pylint: disable=unused-import except ImportError: HAS_PURITY_FB = False -from functools import wraps +# (TODO: remove next line!) +from functools import wraps # noqa: F401, pylint: disable=unused-import from os import environ -from os import path +# (TODO: remove next line!) +from os import path # noqa: F401, pylint: disable=unused-import import platform VERSION = 1.2 diff --git a/plugins/module_utils/version.py b/plugins/module_utils/version.py index b671e59628..3699881978 100644 --- a/plugins/module_utils/version.py +++ b/plugins/module_utils/version.py @@ -13,10 +13,10 @@ __metaclass__ = type from ansible.module_utils.six import raise_from try: - from ansible.module_utils.compat.version import LooseVersion + from ansible.module_utils.compat.version import LooseVersion # noqa: F401, pylint: disable=unused-import except ImportError: try: - from distutils.version import LooseVersion + from distutils.version import LooseVersion # noqa: F401, pylint: disable=unused-import except ImportError as exc: msg = 'To use this plugin or module with ansible-core 2.11, you need to use Python < 3.12 with distutils.version present' raise_from(ImportError(msg), exc) diff --git a/plugins/modules/gitlab_project_variable.py b/plugins/modules/gitlab_project_variable.py index 986847c07b..5e6a2904dc 100644 --- a/plugins/modules/gitlab_project_variable.py +++ b/plugins/modules/gitlab_project_variable.py @@ -182,7 +182,7 @@ from ansible.module_utils.six import integer_types GITLAB_IMP_ERR = None try: - import gitlab + import gitlab # noqa: F401, pylint: disable=unused-import HAS_GITLAB_PACKAGE = True except Exception: GITLAB_IMP_ERR = traceback.format_exc() diff --git a/plugins/modules/jenkins_plugin.py b/plugins/modules/jenkins_plugin.py index c4e1b7fb66..9c4c42e675 100644 --- a/plugins/modules/jenkins_plugin.py +++ b/plugins/modules/jenkins_plugin.py @@ -295,7 +295,6 @@ import io import json import os import tempfile -import time from ansible.module_utils.basic import AnsibleModule, to_bytes from ansible.module_utils.six.moves import http_cookiejar as cookiejar diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 4f56582951..5ec53f9d8c 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -206,7 +206,7 @@ end_state: ''' from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak \ - import KeycloakAPI, camel, keycloak_argument_spec, get_token, KeycloakError, is_struct_included + import KeycloakAPI, keycloak_argument_spec, get_token, KeycloakError, is_struct_included from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/keycloak_client_rolemapping.py b/plugins/modules/keycloak_client_rolemapping.py index f0da97ef59..efb9e77cf7 100644 --- a/plugins/modules/keycloak_client_rolemapping.py +++ b/plugins/modules/keycloak_client_rolemapping.py @@ -201,8 +201,9 @@ end_state: } ''' -from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ - keycloak_argument_spec, get_token, KeycloakError, is_struct_included +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import ( + KeycloakAPI, keycloak_argument_spec, get_token, KeycloakError, +) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/keycloak_clientscope.py b/plugins/modules/keycloak_clientscope.py index 0ac6836f7b..1bba8ba77d 100644 --- a/plugins/modules/keycloak_clientscope.py +++ b/plugins/modules/keycloak_clientscope.py @@ -295,7 +295,7 @@ end_state: ''' from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ - keycloak_argument_spec, get_token, KeycloakError, is_struct_included + keycloak_argument_spec, get_token, KeycloakError from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/keycloak_user_rolemapping.py b/plugins/modules/keycloak_user_rolemapping.py index 72d403c637..9e909716ac 100644 --- a/plugins/modules/keycloak_user_rolemapping.py +++ b/plugins/modules/keycloak_user_rolemapping.py @@ -225,8 +225,8 @@ end_state: } ''' -from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \ - keycloak_argument_spec, get_token, KeycloakError, is_struct_included +from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, \ + keycloak_argument_spec, get_token, KeycloakError from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/lxc_container.py b/plugins/modules/lxc_container.py index 9fe27b8d81..4e7f43419a 100644 --- a/plugins/modules/lxc_container.py +++ b/plugins/modules/lxc_container.py @@ -433,7 +433,7 @@ else: HAS_LXC = True from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.parsing.convert_bool import boolean, BOOLEANS_FALSE +from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE from ansible.module_utils.common.text.converters import to_text, to_bytes diff --git a/plugins/modules/macports.py b/plugins/modules/macports.py index 398a5552e0..7bf5c4f532 100644 --- a/plugins/modules/macports.py +++ b/plugins/modules/macports.py @@ -99,7 +99,6 @@ EXAMPLES = ''' import re from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves import shlex_quote def selfupdate(module, port_path): diff --git a/plugins/modules/manageiq_policies_info.py b/plugins/modules/manageiq_policies_info.py index c10ee95327..8a75ef6464 100644 --- a/plugins/modules/manageiq_policies_info.py +++ b/plugins/modules/manageiq_policies_info.py @@ -81,7 +81,7 @@ profiles: ''' from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.manageiq import ManageIQ, ManageIQPolicies, manageiq_argument_spec, manageiq_entities +from ansible_collections.community.general.plugins.module_utils.manageiq import ManageIQ, manageiq_argument_spec, manageiq_entities def main(): diff --git a/plugins/modules/mas.py b/plugins/modules/mas.py index 49faa53d9d..af77110da7 100644 --- a/plugins/modules/mas.py +++ b/plugins/modules/mas.py @@ -97,7 +97,6 @@ EXAMPLES = ''' RETURN = r''' # ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.common.text.converters import to_native import os from ansible_collections.community.general.plugins.module_utils.version import LooseVersion diff --git a/plugins/modules/memset_zone_record.py b/plugins/modules/memset_zone_record.py index 925a034c56..16a1c3a742 100644 --- a/plugins/modules/memset_zone_record.py +++ b/plugins/modules/memset_zone_record.py @@ -166,7 +166,6 @@ memset_api: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.memset import get_zone_id from ansible_collections.community.general.plugins.module_utils.memset import memset_api_call -from ansible_collections.community.general.plugins.module_utils.memset import get_zone_id def api_validation(args=None): diff --git a/plugins/modules/mksysb.py b/plugins/modules/mksysb.py index 15b6ad9442..39f3e6a1c4 100644 --- a/plugins/modules/mksysb.py +++ b/plugins/modules/mksysb.py @@ -101,10 +101,6 @@ import os from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper -from ansible_collections.community.general.plugins.module_utils.module_helper import ( - ArgFormat -) - class MkSysB(ModuleHelper): module = dict( diff --git a/plugins/modules/ocapi_command.py b/plugins/modules/ocapi_command.py index 7d8fca8064..73c0e22bd5 100644 --- a/plugins/modules/ocapi_command.py +++ b/plugins/modules/ocapi_command.py @@ -165,7 +165,7 @@ operationStatusId: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils from ansible.module_utils.common.text.converters import to_native -from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin +from ansible.module_utils.six.moves.urllib.parse import urljoin # More will be added as module features are expanded CATEGORY_COMMANDS_ALL = { diff --git a/plugins/modules/ocapi_info.py b/plugins/modules/ocapi_info.py index c827b4522d..2cb7a3afca 100644 --- a/plugins/modules/ocapi_info.py +++ b/plugins/modules/ocapi_info.py @@ -141,7 +141,7 @@ status: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils from ansible.module_utils.common.text.converters import to_native -from ansible.module_utils.six.moves.urllib.parse import quote_plus, urljoin +from ansible.module_utils.six.moves.urllib.parse import urljoin # More will be added as module features are expanded CATEGORY_COMMANDS_ALL = { diff --git a/plugins/modules/packet_device.py b/plugins/modules/packet_device.py index 500a400273..a2c2d1d653 100644 --- a/plugins/modules/packet_device.py +++ b/plugins/modules/packet_device.py @@ -292,8 +292,6 @@ try: except ImportError: HAS_PACKET_SDK = False -from ansible.module_utils.basic import AnsibleModule - NAME_RE = r'({0}|{0}{1}*{0})'.format(r'[a-zA-Z0-9]', r'[a-zA-Z0-9\-]') HOSTNAME_RE = r'({0}\.)*{0}$'.format(NAME_RE) diff --git a/plugins/modules/scaleway_compute.py b/plugins/modules/scaleway_compute.py index 3acdc8bd77..0da3f0ff24 100644 --- a/plugins/modules/scaleway_compute.py +++ b/plugins/modules/scaleway_compute.py @@ -177,7 +177,6 @@ import datetime import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves.urllib.parse import quote as urlquote from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway SCALEWAY_SERVER_STATES = ( diff --git a/plugins/modules/scaleway_container.py b/plugins/modules/scaleway_container.py index 6bc237ee39..85e746e1f5 100644 --- a/plugins/modules/scaleway_container.py +++ b/plugins/modules/scaleway_container.py @@ -200,7 +200,7 @@ container: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_container_info.py b/plugins/modules/scaleway_container_info.py index 993919c7ee..670c63a0bc 100644 --- a/plugins/modules/scaleway_container_info.py +++ b/plugins/modules/scaleway_container_info.py @@ -89,7 +89,7 @@ container: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_container_namespace.py b/plugins/modules/scaleway_container_namespace.py index 4cfde73542..e7bf7c71f1 100644 --- a/plugins/modules/scaleway_container_namespace.py +++ b/plugins/modules/scaleway_container_namespace.py @@ -126,7 +126,7 @@ container_namespace: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_container_namespace_info.py b/plugins/modules/scaleway_container_namespace_info.py index fea2d8474b..758720dd57 100644 --- a/plugins/modules/scaleway_container_namespace_info.py +++ b/plugins/modules/scaleway_container_namespace_info.py @@ -81,7 +81,7 @@ container_namespace: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_container_registry.py b/plugins/modules/scaleway_container_registry.py index 294be2cb4c..f49b19917a 100644 --- a/plugins/modules/scaleway_container_registry.py +++ b/plugins/modules/scaleway_container_registry.py @@ -113,7 +113,7 @@ container_registry: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_container_registry_info.py b/plugins/modules/scaleway_container_registry_info.py index c0682cefbe..9c641edcbb 100644 --- a/plugins/modules/scaleway_container_registry_info.py +++ b/plugins/modules/scaleway_container_registry_info.py @@ -80,7 +80,7 @@ container_registry: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_function.py b/plugins/modules/scaleway_function.py index b54091c6ab..5e7ac2a3d1 100644 --- a/plugins/modules/scaleway_function.py +++ b/plugins/modules/scaleway_function.py @@ -184,7 +184,7 @@ function: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_function_info.py b/plugins/modules/scaleway_function_info.py index 14a4cd6289..c30f0cdb00 100644 --- a/plugins/modules/scaleway_function_info.py +++ b/plugins/modules/scaleway_function_info.py @@ -89,7 +89,7 @@ function: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_function_namespace.py b/plugins/modules/scaleway_function_namespace.py index cae4c5ede5..243bb7124c 100644 --- a/plugins/modules/scaleway_function_namespace.py +++ b/plugins/modules/scaleway_function_namespace.py @@ -126,7 +126,7 @@ function_namespace: from copy import deepcopy from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, scaleway_waitable_resource_argument_spec, resource_attributes_should_be_changed, SecretVariables ) diff --git a/plugins/modules/scaleway_function_namespace_info.py b/plugins/modules/scaleway_function_namespace_info.py index bb0b7fa9df..f3ea5ddfc8 100644 --- a/plugins/modules/scaleway_function_namespace_info.py +++ b/plugins/modules/scaleway_function_namespace_info.py @@ -81,7 +81,7 @@ function_namespace: ''' from ansible_collections.community.general.plugins.module_utils.scaleway import ( - SCALEWAY_ENDPOINT, SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway + SCALEWAY_REGIONS, scaleway_argument_spec, Scaleway, ) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/scaleway_security_group_rule.py b/plugins/modules/scaleway_security_group_rule.py index cd27543a7b..52e69868cc 100644 --- a/plugins/modules/scaleway_security_group_rule.py +++ b/plugins/modules/scaleway_security_group_rule.py @@ -133,11 +133,10 @@ data: import traceback from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway, payload_from_object -from ansible.module_utils.common.text.converters import to_text from ansible.module_utils.basic import AnsibleModule, missing_required_lib try: - from ipaddress import ip_network + from ipaddress import ip_network # noqa: F401, pylint: disable=unused-import except ImportError: IPADDRESS_IMP_ERR = traceback.format_exc() HAS_IPADDRESS = False diff --git a/plugins/modules/xenserver_guest_info.py b/plugins/modules/xenserver_guest_info.py index 5cdd52fc56..dd28cf7d07 100644 --- a/plugins/modules/xenserver_guest_info.py +++ b/plugins/modules/xenserver_guest_info.py @@ -153,13 +153,13 @@ instance: HAS_XENAPI = False try: - import XenAPI + import XenAPI # noqa: F401, pylint: disable=unused-import HAS_XENAPI = True except ImportError: pass from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XAPI, XenServerObject, get_object_ref, +from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XenServerObject, get_object_ref, gather_vm_params, gather_vm_facts) diff --git a/plugins/modules/xenserver_guest_powerstate.py b/plugins/modules/xenserver_guest_powerstate.py index 7903ad8b9f..2bb7264875 100644 --- a/plugins/modules/xenserver_guest_powerstate.py +++ b/plugins/modules/xenserver_guest_powerstate.py @@ -173,13 +173,13 @@ instance: HAS_XENAPI = False try: - import XenAPI + import XenAPI # noqa: F401, pylint: disable=unused-import HAS_XENAPI = True except ImportError: pass from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XAPI, XenServerObject, get_object_ref, +from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XenServerObject, get_object_ref, gather_vm_params, gather_vm_facts, set_vm_power_state, wait_for_vm_ip_address)