Make CI pass; add black and isort to CI; add reformat commit to .git-blame-ignore-revs.

This commit is contained in:
Felix Fontein 2025-10-06 18:57:33 +02:00
parent d65d37e9e9
commit bb39e67c8f
11 changed files with 35 additions and 20 deletions

View File

@ -4,3 +4,5 @@
# Reformat YAML: https://github.com/ansible-collections/community.docker/pull/1071
2487d1a0bf4f2c79d3ab5a9e7d0f969432bf32a2
# Reformat with black and isort
d65d37e9e9a78e03a35643704b413121515ee39c

7
.isort.cfg Normal file
View File

@ -0,0 +1,7 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
[isort]
profile=black
lines_after_imports = 2

View File

@ -16,8 +16,9 @@ stable_branches = [ "stable-*" ]
[sessions]
[sessions.lint]
run_isort = false
run_black = false
run_isort = true
isort_config = ".isort.cfg"
run_black = true
run_flake8 = false
run_pylint = false
run_yamllint = true

View File

@ -43,9 +43,9 @@ except ImportError:
try:
from requests.packages import urllib3 # pylint: disable=unused-import
from requests.packages.urllib3 import (
connection as urllib3_connection, # pylint: disable=unused-import
)
# pylint: disable-next=unused-import
from requests.packages.urllib3 import connection as urllib3_connection
except ImportError:
try:
import urllib3 # pylint: disable=unused-import

View File

@ -231,7 +231,7 @@ class APIClient(_Session, DaemonApiMixin):
return version_result["ApiVersion"]
except KeyError:
raise DockerException(
'Invalid response from docker daemon: key "ApiVersion"' " is missing."
'Invalid response from docker daemon: key "ApiVersion" is missing.'
)
except Exception as e:
raise DockerException(

View File

@ -68,7 +68,7 @@ class TLSConfig(object):
tls_cert, tls_key = client_cert
except ValueError:
raise errors.TLSParameterError(
"client_cert must be a tuple of" " (client certificate, key file)"
"client_cert must be a tuple of (client certificate, key file)"
)
if not (tls_cert and tls_key) or (

View File

@ -59,7 +59,7 @@ class NpipeHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
if self.block:
raise urllib3.exceptions.EmptyPoolError(
self,
"Pool reached maximum size and no more " "connections are allowed.",
"Pool reached maximum size and no more connections are allowed.",
)
pass # Oh well, we'll create a new connection then

View File

@ -81,7 +81,7 @@ class SSHSocket(socket.socket):
def _write(self, data):
if not self.proc or self.proc.stdin.closed:
raise Exception(
"SSH subprocess not initiated." "connect() must be called first."
"SSH subprocess not initiated. connect() must be called first."
)
written = self.proc.stdin.write(data)
self.proc.stdin.flush()
@ -96,7 +96,7 @@ class SSHSocket(socket.socket):
def recv(self, n):
if not self.proc:
raise Exception(
"SSH subprocess not initiated." "connect() must be called first."
"SSH subprocess not initiated. connect() must be called first."
)
return self.proc.stdout.read(n)
@ -166,7 +166,7 @@ class SSHConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
if self.block:
raise urllib3.exceptions.EmptyPoolError(
self,
"Pool reached maximum size and no more " "connections are allowed.",
"Pool reached maximum size and no more connections are allowed.",
)
pass # Oh well, we'll create a new connection then

View File

@ -80,6 +80,7 @@ except ImportError:
pass
# pylint: disable=unused-import
from ansible_collections.community.docker.plugins.module_utils.util import (
BYTE_SUFFIXES, # TODO: remove
)
@ -122,7 +123,7 @@ from ansible_collections.community.docker.plugins.module_utils.util import (
from ansible_collections.community.docker.plugins.module_utils.util import (
parse_healthcheck, # TODO: remove
)
from ansible_collections.community.docker.plugins.module_utils.util import ( # noqa: F401, pylint: disable=unused-import
from ansible_collections.community.docker.plugins.module_utils.util import ( # noqa: F401
DEFAULT_DOCKER_HOST,
DEFAULT_TIMEOUT_SECONDS,
DEFAULT_TLS,
@ -135,6 +136,9 @@ from ansible_collections.community.docker.plugins.module_utils.util import ( #
)
# pylint: enable=unused-import
MIN_DOCKER_VERSION = "1.8.0"

View File

@ -43,6 +43,8 @@ from ansible_collections.community.docker.plugins.module_utils._api.utils.utils
convert_filters,
parse_repository_tag,
)
# pylint: disable=unused-import
from ansible_collections.community.docker.plugins.module_utils.util import (
DEFAULT_DOCKER_REGISTRY, # TODO: remove
)
@ -55,7 +57,7 @@ from ansible_collections.community.docker.plugins.module_utils.util import (
from ansible_collections.community.docker.plugins.module_utils.util import (
is_valid_tag, # TODO: remove
)
from ansible_collections.community.docker.plugins.module_utils.util import ( # noqa: F401, pylint: disable=unused-import
from ansible_collections.community.docker.plugins.module_utils.util import ( # noqa: F401
DEFAULT_DOCKER_HOST,
DEFAULT_TIMEOUT_SECONDS,
DEFAULT_TLS,
@ -68,6 +70,9 @@ from ansible_collections.community.docker.plugins.module_utils.util import ( #
)
# pylint: enable=unused-import
def _get_tls_config(fail_function, **kwargs):
try:
tls_config = TLSConfig(**kwargs)

View File

@ -214,9 +214,7 @@ _RE_WARNING_EVENT = re.compile(
r"$" % "|".join(re.escape(status) for status in DOCKER_STATUS_WARNING)
)
_RE_CONTINUE_EVENT = re.compile(
r"^" r"\s*" r"(?P<resource_id>\S+)" r"\s+" r"-" r"\s*" r"(?P<msg>\S(?:|.*\S))" r"$"
)
_RE_CONTINUE_EVENT = re.compile(r"^\s*(?P<resource_id>\S+)\s+-\s*(?P<msg>\S(?:|.*\S))$")
_RE_SKIPPED_EVENT = re.compile(
r"^"
@ -229,11 +227,9 @@ _RE_SKIPPED_EVENT = re.compile(
r"$"
)
_RE_BUILD_START_EVENT = re.compile(
r"^" r"\s*" r"build service" r"\s+" r"(?P<resource_id>\S+)" r"$"
)
_RE_BUILD_START_EVENT = re.compile(r"^\s*build service\s+(?P<resource_id>\S+)$")
_RE_BUILD_PROGRESS_EVENT = re.compile(r"^" r"\s*" r"==>" r"\s+" r"(?P<msg>.*)" r"$")
_RE_BUILD_PROGRESS_EVENT = re.compile(r"^\s*==>\s+(?P<msg>.*)$")
# The following needs to be kept in sync with the MINIMUM_VERSION compose_v2 docs fragment
MINIMUM_COMPOSE_VERSION = "2.18.0"