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
+5 -3
View File
@@ -227,18 +227,20 @@ class APIClient(_Session, DaemonApiMixin):
try:
version_result = self.version(api_version=False)
except Exception as e:
raise DockerException(f"Error while fetching server API version: {e}")
raise DockerException(
f"Error while fetching server API version: {e}"
) from e
try:
return version_result["ApiVersion"]
except KeyError:
raise DockerException(
'Invalid response from docker daemon: key "ApiVersion" is missing.'
)
) from None
except Exception as e:
raise DockerException(
f"Error while fetching server API version: {e}. Response seems to be broken."
)
) from e
def _set_request_timeout(self, kwargs):
"""Prepare the kwargs for an HTTP request by inserting the timeout