From 8c5d9339ecea6b3e09f7f784e3edbb8c5d2b0bce Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 6 Oct 2025 17:50:43 +0200 Subject: [PATCH] Avoid unnecessary string conversion. --- plugins/inventory/docker_containers.py | 2 +- plugins/module_utils/common.py | 10 +++++----- plugins/module_utils/common_api.py | 10 +++++----- plugins/modules/docker_image_info.py | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/inventory/docker_containers.py b/plugins/inventory/docker_containers.py index c3fb241f..df2c6c40 100644 --- a/plugins/inventory/docker_containers.py +++ b/plugins/inventory/docker_containers.py @@ -255,7 +255,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable): try: inspect = client.get_json('/containers/{0}/json', id) except APIError as exc: - raise AnsibleError(f"Error inspecting container {name} - {exc!s}") + raise AnsibleError(f"Error inspecting container {name} - {exc}") state = inspect.get('State') or dict() config = inspect.get('Config') or dict() diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index 84a64825..2954d0d2 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -468,7 +468,7 @@ class AnsibleDockerClientBase(Client): self.log(f"Image {name}:{tag} not found.") return None except Exception as exc: - self.fail(f"Error inspecting image {name}:{tag} - {exc!s}") + self.fail(f"Error inspecting image {name}:{tag} - {exc}") return inspection self.log(f"Image {name}:{tag} not found.") @@ -486,11 +486,11 @@ class AnsibleDockerClientBase(Client): inspection = self.inspect_image(image_id) except NotFound as exc: if not accept_missing_image: - self.fail(f"Error inspecting image ID {image_id} - {exc!s}") + self.fail(f"Error inspecting image ID {image_id} - {exc}") self.log(f"Image {image_id} not found.") return None except Exception as exc: - self.fail(f"Error inspecting image ID {image_id} - {exc!s}") + self.fail(f"Error inspecting image ID {image_id} - {exc}") return inspection def _image_lookup(self, name, tag): @@ -502,7 +502,7 @@ class AnsibleDockerClientBase(Client): try: response = self.images(name=name) except Exception as exc: - self.fail(f"Error searching for image {name} - {exc!s}") + self.fail(f"Error searching for image {name} - {exc}") images = response if tag: lookup = f"{name}:{tag}" @@ -539,7 +539,7 @@ class AnsibleDockerClientBase(Client): else: self.fail(f"Error pulling {name} - {line.get('error')}") except Exception as exc: - self.fail(f"Error pulling image {name}:{tag} - {exc!s}") + self.fail(f"Error pulling image {name}:{tag} - {exc}") new_tag = self.find_image(name, tag) diff --git a/plugins/module_utils/common_api.py b/plugins/module_utils/common_api.py index e97dd6ea..19421255 100644 --- a/plugins/module_utils/common_api.py +++ b/plugins/module_utils/common_api.py @@ -336,7 +336,7 @@ class AnsibleDockerClientBase(Client): params['filters'] = convert_filters({'reference': name}) images = self.get_json("/images/json", params=params) except Exception as exc: - self.fail(f"Error searching for image {name} - {exc!s}") + self.fail(f"Error searching for image {name} - {exc}") if tag: lookup = f"{name}:{tag}" lookup_digest = f"{name}@{tag}" @@ -396,7 +396,7 @@ class AnsibleDockerClientBase(Client): self.log(f"Image {name}:{tag} not found.") return None except Exception as exc: - self.fail(f"Error inspecting image {name}:{tag} - {exc!s}") + self.fail(f"Error inspecting image {name}:{tag} - {exc}") self.log(f"Image {name}:{tag} not found.") return None @@ -413,11 +413,11 @@ class AnsibleDockerClientBase(Client): return self.get_json('/images/{0}/json', image_id) except NotFound as exc: if not accept_missing_image: - self.fail(f"Error inspecting image ID {image_id} - {exc!s}") + self.fail(f"Error inspecting image ID {image_id} - {exc}") self.log(f"Image {image_id} not found.") return None except Exception as exc: - self.fail(f"Error inspecting image ID {image_id} - {exc!s}") + self.fail(f"Error inspecting image ID {image_id} - {exc}") def pull_image(self, name, tag="latest", platform=None): ''' @@ -454,7 +454,7 @@ class AnsibleDockerClientBase(Client): else: self.fail(f"Error pulling {name} - {line.get('error')}") except Exception as exc: - self.fail(f"Error pulling image {name}:{tag} - {exc!s}") + self.fail(f"Error pulling image {name}:{tag} - {exc}") new_tag = self.find_image(name, tag) diff --git a/plugins/modules/docker_image_info.py b/plugins/modules/docker_image_info.py index cc2aca45..3fa8d72d 100644 --- a/plugins/modules/docker_image_info.py +++ b/plugins/modules/docker_image_info.py @@ -158,7 +158,7 @@ class ImageManager(DockerBaseClass): self.client = client self.results = results self.name = self.client.module.params.get('name') - self.log(f"Gathering facts for images: {self.name!s}") + self.log(f"Gathering facts for images: {self.name}") if self.name: self.results['images'] = self.get_facts()