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
+14 -14
View File
@@ -184,19 +184,19 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
raise AnsibleError(msg)
def _populate(self):
raw_params = dict(
docker_host=self.get_option("docker_host"),
tls=self.get_option("tls"),
tls_verify=self.get_option("validate_certs"),
key_path=self.get_option("client_key"),
cacert_path=self.get_option("ca_path"),
cert_path=self.get_option("client_cert"),
tls_hostname=self.get_option("tls_hostname"),
api_version=self.get_option("api_version"),
timeout=self.get_option("timeout"),
use_ssh_client=self.get_option("use_ssh_client"),
debug=None,
)
raw_params = {
"docker_host": self.get_option("docker_host"),
"tls": self.get_option("tls"),
"tls_verify": self.get_option("validate_certs"),
"key_path": self.get_option("client_key"),
"cacert_path": self.get_option("ca_path"),
"cert_path": self.get_option("client_cert"),
"tls_hostname": self.get_option("tls_hostname"),
"api_version": self.get_option("api_version"),
"timeout": self.get_option("timeout"),
"use_ssh_client": self.get_option("use_ssh_client"),
"debug": None,
}
update_tls_hostname(raw_params)
connect_params = get_connect_params(raw_params, fail_function=self._fail)
client = docker.DockerClient(**connect_params)
@@ -305,7 +305,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
except Exception as e:
raise AnsibleError(
f"Unable to fetch hosts from Docker swarm API, this was the original exception: {e}"
)
) from e
def verify_file(self, path):
"""Return the possibly of a file being consumable by this plugin."""