Address some pylint issues (#1155)

* Address cyclic-import.

* Address redefined-builtin.

* Address redefined-argument-from-local.

* Address many redefined-outer-name.

* Address pointless-string-statement.

* No longer needed due to separate bugfix.

* Address useless-return.

* Address possibly-used-before-assignment.

* Add TODOs.

* Address super-init-not-called.

* Address function-redefined.

* Address unspecified-encoding.

* Clean up more imports.
This commit is contained in:
Felix Fontein
2025-10-09 20:11:36 +02:00
committed by GitHub
parent db09affaea
commit a3efa26e2e
42 changed files with 348 additions and 323 deletions
+10 -10
View File
@@ -243,24 +243,24 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
filters = parse_filters(self.get_option("filters"))
for container in containers:
id = container.get("Id")
short_id = id[:13]
container_id = container.get("Id")
short_container_id = container_id[:13]
try:
name = container.get("Names", list())[0].lstrip("/")
full_name = name
except IndexError:
name = short_id
full_name = id
name = short_container_id
full_name = container_id
facts = dict(
docker_name=make_unsafe(name),
docker_short_id=make_unsafe(short_id),
docker_short_id=make_unsafe(short_container_id),
)
full_facts = dict()
try:
inspect = client.get_json("/containers/{0}/json", id)
inspect = client.get_json("/containers/{0}/json", container_id)
except APIError as exc:
raise AnsibleError(f"Error inspecting container {name} - {exc}")
@@ -371,12 +371,12 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
# When we do this before a set_variable() call, the variables are assigned
# to the group, and not to the host.
if add_legacy_groups:
self.inventory.add_group(id)
self.inventory.add_host(name, group=id)
self.inventory.add_group(container_id)
self.inventory.add_host(name, group=container_id)
self.inventory.add_group(name)
self.inventory.add_host(name, group=name)
self.inventory.add_group(short_id)
self.inventory.add_host(name, group=short_id)
self.inventory.add_group(short_container_id)
self.inventory.add_host(name, group=short_container_id)
self.inventory.add_group(hostname)
self.inventory.add_host(name, group=hostname)
+3 -3
View File
@@ -170,15 +170,15 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
# capture any of the DOCKER_xxx variables that were output and create Ansible host vars
# with the same name and value but with a dm_ name prefix.
vars = []
env_vars = []
for line in env_lines:
match = re.search('(DOCKER_[^=]+)="([^"]+)"', line)
if match:
env_var_name = match.group(1)
env_var_value = match.group(2)
vars.append((env_var_name, env_var_value))
env_vars.append((env_var_name, env_var_value))
return vars
return env_vars
def _get_machine_names(self):
# Filter out machines that are not in the Running state as we probably cannot do anything useful actions