Python code modernization, 5/n (#1165)

* Address raise-missing-from.

* Address simplifiable-if-expression.

* Address unnecessary-dunder-call.

* Address unnecessary-pass.

* Address use-list-literal.

* Address unused-variable.

* Address use-dict-literal.
This commit is contained in:
Felix Fontein
2025-10-12 16:02:27 +02:00
committed by GitHub
parent cad22de628
commit c75aa5dd64
66 changed files with 1549 additions and 1429 deletions
+7 -7
View File
@@ -167,8 +167,8 @@ class Connection(ConnectionBase):
else:
try:
self.docker_cmd = get_bin_path("docker")
except ValueError:
raise AnsibleError("docker command not found in PATH")
except ValueError as exc:
raise AnsibleError("docker command not found in PATH") from exc
@staticmethod
def _sanitize_version(version):
@@ -426,7 +426,7 @@ class Connection(ConnectionBase):
)
chunks = b""
for key, event in events:
for key, dummy_event in events:
if key.fileobj == p.stdout:
chunk = p.stdout.read()
if chunk:
@@ -523,10 +523,10 @@ class Connection(ConnectionBase):
p = subprocess.Popen(
args, stdin=in_file, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
except OSError:
except OSError as exc:
raise AnsibleError(
"docker connection requires dd command in the container to put files"
)
) from exc
stdout, stderr = p.communicate()
if p.returncode != 0:
@@ -588,10 +588,10 @@ class Connection(ConnectionBase):
stdout=out_file,
stderr=subprocess.PIPE,
)
except OSError:
except OSError as exc:
raise AnsibleError(
"docker connection requires dd command in the container to put files"
)
) from exc
stdout, stderr = pp.communicate()
if pp.returncode != 0: