mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 11:32:05 +00:00
Fix issues with pylint 4.0.
This commit is contained in:
parent
16b5bfa27b
commit
6f9ebc3f14
@ -14,10 +14,6 @@ from __future__ import annotations
|
||||
import traceback
|
||||
|
||||
|
||||
REQUESTS_IMPORT_ERROR = None
|
||||
URLLIB3_IMPORT_ERROR = None
|
||||
|
||||
|
||||
try:
|
||||
from requests import Session # noqa: F401, pylint: disable=unused-import
|
||||
from requests.adapters import ( # noqa: F401, pylint: disable=unused-import
|
||||
@ -28,7 +24,7 @@ try:
|
||||
InvalidSchema,
|
||||
)
|
||||
except ImportError:
|
||||
REQUESTS_IMPORT_ERROR = traceback.format_exc()
|
||||
REQUESTS_IMPORT_ERROR = traceback.format_exc() # pylint: disable=invalid-name
|
||||
|
||||
class Session:
|
||||
__attrs__ = []
|
||||
@ -42,7 +38,11 @@ except ImportError:
|
||||
class InvalidSchema(Exception):
|
||||
pass
|
||||
|
||||
else:
|
||||
REQUESTS_IMPORT_ERROR = None # pylint: disable=invalid-name
|
||||
|
||||
|
||||
URLLIB3_IMPORT_ERROR = None # pylint: disable=invalid-name
|
||||
try:
|
||||
from requests.packages import urllib3 # pylint: disable=unused-import
|
||||
|
||||
@ -55,7 +55,7 @@ except ImportError:
|
||||
connection as urllib3_connection, # pylint: disable=unused-import
|
||||
)
|
||||
except ImportError:
|
||||
URLLIB3_IMPORT_ERROR = traceback.format_exc()
|
||||
URLLIB3_IMPORT_ERROR = traceback.format_exc() # pylint: disable=invalid-name
|
||||
|
||||
class _HTTPConnectionPool:
|
||||
pass
|
||||
|
||||
@ -17,7 +17,6 @@ import time
|
||||
import traceback
|
||||
|
||||
|
||||
PYWIN32_IMPORT_ERROR = None
|
||||
try:
|
||||
import pywintypes
|
||||
import win32api
|
||||
@ -25,7 +24,9 @@ try:
|
||||
import win32file
|
||||
import win32pipe
|
||||
except ImportError:
|
||||
PYWIN32_IMPORT_ERROR = traceback.format_exc()
|
||||
PYWIN32_IMPORT_ERROR = traceback.format_exc() # pylint: disable=invalid-name
|
||||
else:
|
||||
PYWIN32_IMPORT_ERROR = None # pylint: disable=invalid-name
|
||||
|
||||
|
||||
ERROR_PIPE_BUSY = 0xE7
|
||||
|
||||
@ -25,11 +25,12 @@ from .._import_helper import HTTPAdapter, urllib3, urllib3_connection
|
||||
from .basehttpadapter import BaseHTTPAdapter
|
||||
|
||||
|
||||
PARAMIKO_IMPORT_ERROR = None
|
||||
try:
|
||||
import paramiko
|
||||
except ImportError:
|
||||
PARAMIKO_IMPORT_ERROR = traceback.format_exc()
|
||||
PARAMIKO_IMPORT_ERROR = traceback.format_exc() # pylint: disable=invalid-name
|
||||
else:
|
||||
PARAMIKO_IMPORT_ERROR = None # pylint: disable=invalid-name
|
||||
|
||||
|
||||
RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer
|
||||
|
||||
@ -34,11 +34,8 @@ from ansible_collections.community.docker.plugins.module_utils._version import (
|
||||
)
|
||||
|
||||
|
||||
HAS_DOCKER_PY = True
|
||||
HAS_DOCKER_PY_2 = False
|
||||
HAS_DOCKER_PY_3 = False
|
||||
HAS_DOCKER_ERROR = None
|
||||
HAS_DOCKER_TRACEBACK = None
|
||||
HAS_DOCKER_PY_2 = False # pylint: disable=invalid-name
|
||||
HAS_DOCKER_PY_3 = False # pylint: disable=invalid-name
|
||||
|
||||
try:
|
||||
from docker import __version__ as docker_version
|
||||
@ -48,18 +45,22 @@ try:
|
||||
from requests.exceptions import SSLError
|
||||
|
||||
if LooseVersion(docker_version) >= LooseVersion("3.0.0"):
|
||||
HAS_DOCKER_PY_3 = True
|
||||
HAS_DOCKER_PY_3 = True # pylint: disable=invalid-name
|
||||
from docker import APIClient as Client
|
||||
elif LooseVersion(docker_version) >= LooseVersion("2.0.0"):
|
||||
HAS_DOCKER_PY_2 = True
|
||||
HAS_DOCKER_PY_2 = True # pylint: disable=invalid-name
|
||||
from docker import APIClient as Client
|
||||
else:
|
||||
from docker import Client
|
||||
|
||||
except ImportError as exc:
|
||||
HAS_DOCKER_ERROR = str(exc)
|
||||
HAS_DOCKER_TRACEBACK = traceback.format_exc()
|
||||
HAS_DOCKER_PY = False
|
||||
HAS_DOCKER_ERROR = str(exc) # pylint: disable=invalid-name
|
||||
HAS_DOCKER_TRACEBACK = traceback.format_exc() # pylint: disable=invalid-name
|
||||
HAS_DOCKER_PY = False # pylint: disable=invalid-name
|
||||
else:
|
||||
HAS_DOCKER_PY = True # pylint: disable=invalid-name
|
||||
HAS_DOCKER_ERROR = None # pylint: disable=invalid-name
|
||||
HAS_DOCKER_TRACEBACK = None # pylint: disable=invalid-name
|
||||
|
||||
|
||||
# The next two imports ``docker.models`` and ``docker.ssladapter`` are used
|
||||
|
||||
@ -42,11 +42,12 @@ try:
|
||||
from yaml import CSafeDumper as _SafeDumper
|
||||
except ImportError:
|
||||
from yaml import SafeDumper as _SafeDumper
|
||||
HAS_PYYAML = True
|
||||
PYYAML_IMPORT_ERROR = None
|
||||
except ImportError:
|
||||
HAS_PYYAML = False
|
||||
PYYAML_IMPORT_ERROR = traceback.format_exc()
|
||||
PYYAML_IMPORT_ERROR = traceback.format_exc() # pylint: disable=invalid-name
|
||||
else:
|
||||
HAS_PYYAML = True
|
||||
PYYAML_IMPORT_ERROR = None # pylint: disable=invalid-name
|
||||
|
||||
|
||||
DOCKER_COMPOSE_FILES = (
|
||||
|
||||
@ -17,14 +17,12 @@ from ansible_collections.community.docker.plugins.module_utils._api.transport im
|
||||
)
|
||||
|
||||
|
||||
HAS_MATCH_HOSTNAME = True
|
||||
try:
|
||||
from backports.ssl_match_hostname import CertificateError, match_hostname
|
||||
from ssl import CertificateError, match_hostname
|
||||
except ImportError:
|
||||
try:
|
||||
from ssl import CertificateError, match_hostname
|
||||
except ImportError:
|
||||
HAS_MATCH_HOSTNAME = False
|
||||
HAS_MATCH_HOSTNAME = False # pylint: disable=invalid-name
|
||||
else:
|
||||
HAS_MATCH_HOSTNAME = True # pylint: disable=invalid-name
|
||||
|
||||
try:
|
||||
from ssl import OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user