Ignore necessary unused imports in module_utils (#79904)

pull/79910/head
Matt Clay 2 years ago committed by GitHub
parent 9e2aad6e51
commit 3b4f3c066a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@ __metaclass__ = type
""" """
# Backwards compat for people still calling it from this package # Backwards compat for people still calling it from this package
# pylint: disable=unused-import
import codecs import codecs
from ansible.module_utils.six import PY3, text_type, binary_type from ansible.module_utils.six import PY3, text_type, binary_type

@ -12,7 +12,7 @@ __metaclass__ = type
try: try:
"""Python 3.3+ branch.""" """Python 3.3+ branch."""
from collections.abc import ( from collections.abc import ( # pylint: disable=unused-import
MappingView, MappingView,
ItemsView, ItemsView,
KeysView, KeysView,

@ -8,7 +8,7 @@ __metaclass__ = type
from ansible.module_utils.six import binary_type, text_type 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): class ImmutableDict(Hashable, Mapping):

@ -15,7 +15,7 @@ from contextlib import contextmanager
from ansible.module_utils.common.warnings import deprecate from ansible.module_utils.common.warnings import deprecate
try: try:
import selinux import selinux # pylint: disable=unused-import
HAVE_SELINUX = True HAVE_SELINUX = True
except ImportError: except ImportError:
HAVE_SELINUX = False HAVE_SELINUX = False

@ -24,13 +24,13 @@ if HAS_YAML:
try: try:
from yaml import CSafeLoader as SafeLoader from yaml import CSafeLoader as SafeLoader
from yaml import CSafeDumper as SafeDumper 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 HAS_LIBYAML = True
except (ImportError, AttributeError): except (ImportError, AttributeError):
from yaml import SafeLoader # type: ignore[assignment] from yaml import SafeLoader # type: ignore[assignment]
from yaml import SafeDumper # 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 = _partial(_yaml.load, Loader=SafeLoader)
yaml_load_all = _partial(_yaml.load_all, Loader=SafeLoader) yaml_load_all = _partial(_yaml.load_all, Loader=SafeLoader)

@ -8,7 +8,7 @@ __metaclass__ = type
import sys import sys
try: try:
from importlib import import_module from importlib import import_module # pylint: disable=unused-import
except ImportError: except ImportError:
# importlib.import_module returns the tail # importlib.import_module returns the tail
# whereas __import__ returns the head # whereas __import__ returns the head

@ -5,7 +5,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import types import types # pylint: disable=unused-import
import warnings import warnings
PARAMIKO_IMPORT_ERR = None PARAMIKO_IMPORT_ERR = None
@ -13,7 +13,7 @@ PARAMIKO_IMPORT_ERR = None
try: try:
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='Blowfish has been deprecated', category=UserWarning) 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 # paramiko and gssapi are incompatible and raise AttributeError not ImportError
# When running in FIPS mode, cryptography raises InternalError # When running in FIPS mode, cryptography raises InternalError
# https://bugzilla.redhat.com/show_bug.cgi?id=1778939 # https://bugzilla.redhat.com/show_bug.cgi?id=1778939

@ -36,7 +36,7 @@ _BUNDLED_METADATA = {"pypi_name": "selectors2", "version": "1.1.1", "version_con
# interrupted syscalls work with kqueue # interrupted syscalls work with kqueue
import sys import sys
import types import types # pylint: disable=unused-import
try: try:
# Python 3.4+ # Python 3.4+

@ -27,7 +27,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __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 # NB: a copy of this function exists in ../../modules/core/async_wrapper.py. Ensure any

@ -53,7 +53,7 @@ import socket
import sys import sys
import tempfile import tempfile
import traceback import traceback
import types import types # pylint: disable=unused-import
from contextlib import contextmanager from contextlib import contextmanager
@ -115,7 +115,7 @@ except Exception:
try: try:
# SNI Handling needs python2.7.9's SSLContext # 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 HAS_SSLCONTEXT = True
except ImportError: except ImportError:
HAS_SSLCONTEXT = False HAS_SSLCONTEXT = False
@ -196,7 +196,7 @@ except ImportError:
# Old import for GSSAPI authentication, this is not used in urls.py but kept for backwards compatibility. # Old import for GSSAPI authentication, this is not used in urls.py but kept for backwards compatibility.
try: try:
import urllib_gssapi import urllib_gssapi # pylint: disable=unused-import
HAS_GSSAPI = True HAS_GSSAPI = True
except ImportError: except ImportError:
HAS_GSSAPI = False HAS_GSSAPI = False

Loading…
Cancel
Save