From 51fadd0aac55cacc1fcbe6e9e11c239ad32f0bdb Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 3 Feb 2023 14:40:55 -0800 Subject: [PATCH] Clean up unused imports in plugins (#79899) --- changelogs/fragments/unused-imports-plugins.yml | 6 ++++++ lib/ansible/plugins/action/async_status.py | 1 - lib/ansible/plugins/action/command.py | 1 - lib/ansible/plugins/action/pause.py | 3 +-- lib/ansible/plugins/action/set_stats.py | 1 - lib/ansible/plugins/action/uri.py | 1 - lib/ansible/plugins/action/validate_argument_spec.py | 2 -- lib/ansible/plugins/cache/base.py | 2 +- lib/ansible/plugins/connection/winrm.py | 2 +- lib/ansible/plugins/lookup/fileglob.py | 1 - lib/ansible/plugins/lookup/template.py | 2 +- lib/ansible/plugins/strategy/debug.py | 4 ---- lib/ansible/plugins/test/files.py | 1 - lib/ansible/plugins/vars/host_group_vars.py | 1 - 14 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 changelogs/fragments/unused-imports-plugins.yml diff --git a/changelogs/fragments/unused-imports-plugins.yml b/changelogs/fragments/unused-imports-plugins.yml new file mode 100644 index 00000000000..2e53edfe0fa --- /dev/null +++ b/changelogs/fragments/unused-imports-plugins.yml @@ -0,0 +1,6 @@ +minor_changes: + - "Removed unused imports from the following action plugins: async_status, command, pause, set_stats, uri, validate_argument_spec" + - "Removed unused imports from the following lookup plugins: fileglob, template" + - "Removed unused imports from the following strategy plugins: debug" + - "Removed unused imports from the following set of test plugins: files" + - "Removed unused imports from the following vars plugins: host_group_vars" diff --git a/lib/ansible/plugins/action/async_status.py b/lib/ansible/plugins/action/async_status.py index ad839f1e347..4f50fe62f8e 100644 --- a/lib/ansible/plugins/action/async_status.py +++ b/lib/ansible/plugins/action/async_status.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible.errors import AnsibleActionFail from ansible.plugins.action import ActionBase from ansible.utils.vars import merge_hash diff --git a/lib/ansible/plugins/action/command.py b/lib/ansible/plugins/action/command.py index 82a85dcd33a..64e1a094011 100644 --- a/lib/ansible/plugins/action/command.py +++ b/lib/ansible/plugins/action/command.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible import constants as C from ansible.plugins.action import ActionBase from ansible.utils.vars import merge_hash diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py index 4c98cbbff51..7b8ecee65ef 100644 --- a/lib/ansible/plugins/action/pause.py +++ b/lib/ansible/plugins/action/pause.py @@ -30,8 +30,7 @@ from os import ( tcgetpgrp, ) from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text, to_native -from ansible.module_utils.parsing.convert_bool import boolean +from ansible.module_utils._text import to_text from ansible.plugins.action import ActionBase from ansible.utils.display import Display diff --git a/lib/ansible/plugins/action/set_stats.py b/lib/ansible/plugins/action/set_stats.py index 9d429ced8dd..16a7747b2b4 100644 --- a/lib/ansible/plugins/action/set_stats.py +++ b/lib/ansible/plugins/action/set_stats.py @@ -18,7 +18,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible.module_utils.six import string_types from ansible.module_utils.parsing.convert_bool import boolean from ansible.plugins.action import ActionBase from ansible.utils.vars import isidentifier diff --git a/lib/ansible/plugins/action/uri.py b/lib/ansible/plugins/action/uri.py index bbaf092e1d0..e6f99d0ef82 100644 --- a/lib/ansible/plugins/action/uri.py +++ b/lib/ansible/plugins/action/uri.py @@ -13,7 +13,6 @@ from ansible.errors import AnsibleError, AnsibleAction, _AnsibleActionDone, Ansi from ansible.module_utils._text import to_native from ansible.module_utils.common.collections import Mapping, MutableMapping from ansible.module_utils.parsing.convert_bool import boolean -from ansible.module_utils.six import text_type from ansible.plugins.action import ActionBase diff --git a/lib/ansible/plugins/action/validate_argument_spec.py b/lib/ansible/plugins/action/validate_argument_spec.py index dc7d6cb3b90..1fcfa595893 100644 --- a/lib/ansible/plugins/action/validate_argument_spec.py +++ b/lib/ansible/plugins/action/validate_argument_spec.py @@ -6,9 +6,7 @@ __metaclass__ = type from ansible.errors import AnsibleError from ansible.plugins.action import ActionBase -from ansible.module_utils.six import string_types from ansible.module_utils.common.arg_spec import ArgumentSpecValidator -from ansible.module_utils.errors import AnsibleValidationErrorMultiple from ansible.utils.vars import combine_vars diff --git a/lib/ansible/plugins/cache/base.py b/lib/ansible/plugins/cache/base.py index 692b1b37165..a947eb72cc9 100644 --- a/lib/ansible/plugins/cache/base.py +++ b/lib/ansible/plugins/cache/base.py @@ -18,4 +18,4 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type # moved actual classes to __init__ kept here for backward compat with 3rd parties -from ansible.plugins.cache import BaseCacheModule, BaseFileCacheModule +from ansible.plugins.cache import BaseCacheModule, BaseFileCacheModule # pylint: disable=unused-import diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index 65fdcd656c7..a8a2ed658d7 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -176,7 +176,7 @@ from urllib.parse import urlunsplit HAVE_KERBEROS = False try: - import kerberos + import kerberos # pylint: disable=unused-import HAVE_KERBEROS = True except ImportError: pass diff --git a/lib/ansible/plugins/lookup/fileglob.py b/lib/ansible/plugins/lookup/fileglob.py index abf8202ef45..1b068fbe6a0 100644 --- a/lib/ansible/plugins/lookup/fileglob.py +++ b/lib/ansible/plugins/lookup/fileglob.py @@ -50,7 +50,6 @@ import os import glob from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleFileNotFound from ansible.module_utils._text import to_bytes, to_text diff --git a/lib/ansible/plugins/lookup/template.py b/lib/ansible/plugins/lookup/template.py index 9c575b53acd..ec47624c15c 100644 --- a/lib/ansible/plugins/lookup/template.py +++ b/lib/ansible/plugins/lookup/template.py @@ -84,7 +84,7 @@ import ansible.constants as C from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase -from ansible.module_utils._text import to_bytes, to_text +from ansible.module_utils._text import to_text from ansible.template import generate_ansible_template_vars, AnsibleEnvironment from ansible.utils.display import Display from ansible.utils.native_jinja import NativeJinjaText diff --git a/lib/ansible/plugins/strategy/debug.py b/lib/ansible/plugins/strategy/debug.py index f808bcfa0d2..0965bb37d46 100644 --- a/lib/ansible/plugins/strategy/debug.py +++ b/lib/ansible/plugins/strategy/debug.py @@ -24,10 +24,6 @@ DOCUMENTATION = ''' author: Kishin Yagami (!UNKNOWN) ''' -import cmd -import pprint -import sys - from ansible.plugins.strategy.linear import StrategyModule as LinearStrategyModule diff --git a/lib/ansible/plugins/test/files.py b/lib/ansible/plugins/test/files.py index 35761a45f4e..f075cae8040 100644 --- a/lib/ansible/plugins/test/files.py +++ b/lib/ansible/plugins/test/files.py @@ -20,7 +20,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from os.path import isdir, isfile, isabs, exists, lexists, islink, samefile, ismount -from ansible import errors class TestModule(object): diff --git a/lib/ansible/plugins/vars/host_group_vars.py b/lib/ansible/plugins/vars/host_group_vars.py index 521b3b6eddc..26b15fdaaff 100644 --- a/lib/ansible/plugins/vars/host_group_vars.py +++ b/lib/ansible/plugins/vars/host_group_vars.py @@ -54,7 +54,6 @@ DOCUMENTATION = ''' ''' import os -from ansible import constants as C from ansible.errors import AnsibleParserError from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.plugins.vars import BaseVarsPlugin