mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 03:46:55 +00:00
Add more CI checks (#1150)
* Enable mypy. * Add flake8. * Add pylint with a long list of ignores to be removed.
This commit is contained in:
@@ -387,7 +387,7 @@ class AnsibleDockerClientBase(Client):
|
||||
result = self.inspect_container(container=container_id)
|
||||
self.log("Completed container inspection")
|
||||
return result
|
||||
except NotFound as dummy:
|
||||
except NotFound:
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail(f"Error inspecting container: {exc}")
|
||||
@@ -461,7 +461,7 @@ class AnsibleDockerClientBase(Client):
|
||||
self.log(f"Inspecting network Id {network_id}")
|
||||
result = self.inspect_network(network_id)
|
||||
self.log("Completed network inspection")
|
||||
except NotFound as dummy:
|
||||
except NotFound:
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail(f"Error inspecting network: {exc}")
|
||||
|
||||
@@ -287,7 +287,7 @@ class AnsibleDockerClientBase(Client):
|
||||
result = self.get_json("/containers/{0}/json", container_id)
|
||||
self.log("Completed container inspection")
|
||||
return result
|
||||
except NotFound as dummy:
|
||||
except NotFound:
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail(f"Error inspecting container: {exc}")
|
||||
@@ -369,7 +369,7 @@ class AnsibleDockerClientBase(Client):
|
||||
self.log(f"Inspecting network Id {network_id}")
|
||||
result = self.get_json("/networks/{0}", network_id)
|
||||
self.log("Completed network inspection")
|
||||
except NotFound as dummy:
|
||||
except NotFound:
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail(f"Error inspecting network: {exc}")
|
||||
|
||||
@@ -229,8 +229,6 @@ class AnsibleDockerClientBase(object):
|
||||
check_rc=True,
|
||||
)
|
||||
if tag:
|
||||
lookup = f"{name}:{tag}"
|
||||
lookup_digest = f"{name}@{tag}"
|
||||
response = images
|
||||
images = []
|
||||
for image in response:
|
||||
|
||||
@@ -706,7 +706,7 @@ def _preprocess_mounts(module, values):
|
||||
if mount_dict["tmpfs_mode"] is not None:
|
||||
try:
|
||||
mount_dict["tmpfs_mode"] = int(mount_dict["tmpfs_mode"], 8)
|
||||
except Exception as dummy:
|
||||
except Exception:
|
||||
module.fail_json(
|
||||
msg=f'tmp_fs mode of mount "{target}" is not an octal string!'
|
||||
)
|
||||
|
||||
@@ -419,7 +419,7 @@ class DockerAPIEngineDriver(EngineDriver):
|
||||
while True:
|
||||
try:
|
||||
client.delete_call("/containers/{0}", container_id, params=params)
|
||||
except NotFound as dummy:
|
||||
except NotFound:
|
||||
pass
|
||||
except APIError as exc:
|
||||
if (
|
||||
@@ -548,7 +548,6 @@ class DockerAPIEngine(Engine):
|
||||
return {}
|
||||
return {options[0].name: value}
|
||||
|
||||
get_expected_values_ = None
|
||||
if get_expected_value:
|
||||
|
||||
def get_expected_values_(
|
||||
@@ -566,6 +565,9 @@ class DockerAPIEngine(Engine):
|
||||
return values
|
||||
return {options[0].name: value}
|
||||
|
||||
else:
|
||||
get_expected_values_ = None
|
||||
|
||||
def set_value(module, data, api_version, options, values):
|
||||
if len(options) != 1:
|
||||
raise AssertionError(
|
||||
@@ -578,7 +580,6 @@ class DockerAPIEngine(Engine):
|
||||
value = preprocess_for_set(module, api_version, value)
|
||||
data[config_name] = value
|
||||
|
||||
update_value = None
|
||||
if update_parameter:
|
||||
|
||||
def update_value(module, data, api_version, options, values):
|
||||
@@ -593,6 +594,9 @@ class DockerAPIEngine(Engine):
|
||||
value = preprocess_for_set(module, api_version, value)
|
||||
data[update_parameter] = value
|
||||
|
||||
else:
|
||||
update_value = None
|
||||
|
||||
return cls(
|
||||
get_value=get_value,
|
||||
preprocess_value=preprocess_value_,
|
||||
@@ -644,7 +648,6 @@ class DockerAPIEngine(Engine):
|
||||
return {}
|
||||
return {options[0].name: value}
|
||||
|
||||
get_expected_values_ = None
|
||||
if get_expected_value:
|
||||
|
||||
def get_expected_values_(
|
||||
@@ -662,6 +665,9 @@ class DockerAPIEngine(Engine):
|
||||
return values
|
||||
return {options[0].name: value}
|
||||
|
||||
else:
|
||||
get_expected_values_ = None
|
||||
|
||||
def set_value(module, data, api_version, options, values):
|
||||
if len(options) != 1:
|
||||
raise AssertionError(
|
||||
@@ -676,7 +682,6 @@ class DockerAPIEngine(Engine):
|
||||
value = preprocess_for_set(module, api_version, value)
|
||||
data["HostConfig"][host_config_name] = value
|
||||
|
||||
update_value = None
|
||||
if update_parameter:
|
||||
|
||||
def update_value(module, data, api_version, options, values):
|
||||
@@ -691,6 +696,9 @@ class DockerAPIEngine(Engine):
|
||||
value = preprocess_for_set(module, api_version, value)
|
||||
data[update_parameter] = value
|
||||
|
||||
else:
|
||||
update_value = None
|
||||
|
||||
return cls(
|
||||
get_value=get_value,
|
||||
preprocess_value=preprocess_value_,
|
||||
|
||||
@@ -484,7 +484,7 @@ class ServicesManager(BaseComposeManager):
|
||||
self.fail(f"The key {key!r} for `scale` is not a string")
|
||||
try:
|
||||
value = check_type_int(value)
|
||||
except TypeError as exc:
|
||||
except TypeError:
|
||||
self.fail(f"The value {value!r} for `scale[{key!r}]` is not an integer")
|
||||
if value < 0:
|
||||
self.fail(f"The value {value!r} for `scale[{key!r}]` is negative")
|
||||
|
||||
@@ -85,7 +85,7 @@ from ansible_collections.community.docker.plugins.module_utils._common_api impor
|
||||
def get_existing_volume(client, volume_name):
|
||||
try:
|
||||
return client.get_json("/volumes/{0}", volume_name)
|
||||
except NotFound as dummy:
|
||||
except NotFound:
|
||||
return None
|
||||
except Exception as exc:
|
||||
client.fail(f"Error inspecting volume: {exc}")
|
||||
|
||||
Reference in New Issue
Block a user