Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore necessary unused imports in module_utils #79904

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ansible/module_utils/_text.py
Expand Up @@ -8,6 +8,7 @@
"""

# Backwards compat for people still calling it from this package
# pylint: disable=unused-import
import codecs

from ansible.module_utils.six import PY3, text_type, binary_type
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/common/_collections_compat.py
Expand Up @@ -12,7 +12,7 @@

try:
"""Python 3.3+ branch."""
from collections.abc import (
from collections.abc import ( # pylint: disable=unused-import
MappingView,
ItemsView,
KeysView,
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/common/collections.py
Expand Up @@ -8,7 +8,7 @@


from ansible.module_utils.six import binary_type, text_type
from ansible.module_utils.common._collections_compat import Hashable, Mapping, MutableMapping, Sequence
from ansible.module_utils.common._collections_compat import Hashable, Mapping, MutableMapping, Sequence # pylint: disable=unused-import


class ImmutableDict(Hashable, Mapping):
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/common/file.py
Expand Up @@ -22,7 +22,7 @@
from ansible.module_utils.common.warnings import deprecate

try:
import selinux
import selinux # pylint: disable=unused-import
HAVE_SELINUX = True
except ImportError:
HAVE_SELINUX = False
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/module_utils/common/yaml.py
Expand Up @@ -24,13 +24,13 @@
try:
from yaml import CSafeLoader as SafeLoader
from yaml import CSafeDumper as SafeDumper
from yaml.cyaml import CParser as Parser # type: ignore[attr-defined]
from yaml.cyaml import CParser as Parser # type: ignore[attr-defined] # pylint: disable=unused-import

HAS_LIBYAML = True
except (ImportError, AttributeError):
from yaml import SafeLoader # type: ignore[assignment]
from yaml import SafeDumper # type: ignore[assignment]
from yaml.parser import Parser # type: ignore[misc]
from yaml.parser import Parser # type: ignore[misc] # pylint: disable=unused-import

yaml_load = _partial(_yaml.load, Loader=SafeLoader)
yaml_load_all = _partial(_yaml.load_all, Loader=SafeLoader)
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/compat/importlib.py
Expand Up @@ -8,7 +8,7 @@
import sys

try:
from importlib import import_module
from importlib import import_module # pylint: disable=unused-import
except ImportError:
# importlib.import_module returns the tail
# whereas __import__ returns the head
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/module_utils/compat/paramiko.py
Expand Up @@ -5,15 +5,15 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type

import types
import types # pylint: disable=unused-import
import warnings

PARAMIKO_IMPORT_ERR = None

try:
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='Blowfish has been deprecated', category=UserWarning)
import paramiko
import paramiko # pylint: disable=unused-import
# paramiko and gssapi are incompatible and raise AttributeError not ImportError
# When running in FIPS mode, cryptography raises InternalError
# https://bugzilla.redhat.com/show_bug.cgi?id=1778939
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/compat/selectors.py
Expand Up @@ -37,7 +37,7 @@

import os.path
import sys
import types
import types # pylint: disable=unused-import

try:
# Python 3.4+
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/json_utils.py
Expand Up @@ -27,7 +27,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import json
import json # pylint: disable=unused-import


# NB: a copy of this function exists in ../../modules/core/async_wrapper.py. Ensure any
Expand Down
6 changes: 3 additions & 3 deletions lib/ansible/module_utils/urls.py
Expand Up @@ -53,7 +53,7 @@
import sys
import tempfile
import traceback
import types
import types # pylint: disable=unused-import

from contextlib import contextmanager

Expand Down Expand Up @@ -115,7 +115,7 @@

try:
# SNI Handling needs python2.7.9's SSLContext
from ssl import create_default_context, SSLContext
from ssl import create_default_context, SSLContext # pylint: disable=unused-import
HAS_SSLCONTEXT = True
except ImportError:
HAS_SSLCONTEXT = False
Expand Down Expand Up @@ -196,7 +196,7 @@

# Old import for GSSAPI authentication, this is not used in urls.py but kept for backwards compatibility.
try:
import urllib_gssapi
import urllib_gssapi # pylint: disable=unused-import
HAS_GSSAPI = True
except ImportError:
HAS_GSSAPI = False
Expand Down