Address possibly-used-before-assignment.

This commit is contained in:
Felix Fontein 2025-10-07 22:06:24 +02:00
parent 776f95f295
commit 25f89d3663
5 changed files with 7 additions and 2 deletions

View File

@ -402,7 +402,6 @@ disable=raw-checker-failed,
no-member,
no-name-in-module,
not-an-iterable,
possibly-used-before-assignment,
protected-access,
raise-missing-from,
redefined-outer-name, # needed for test fixtures

View File

@ -425,11 +425,13 @@ class Connection(ConnectionBase):
+ to_native(become_output)
)
chunk = None
for key, event in events:
if key.fileobj == p.stdout:
chunk = p.stdout.read()
elif key.fileobj == p.stderr:
chunk = p.stderr.read()
# TODO: avoid chunk being set multiple times!
if not chunk:
stdout, stderr = p.communicate()

View File

@ -177,11 +177,13 @@ class Connection(ConnectionBase):
+ to_native(become_output)
)
chunk = None
for key, event in events:
if key.fileobj == p.stdout:
chunk = p.stdout.read()
elif key.fileobj == p.stderr:
chunk = p.stderr.read()
# TODO: avoid chunk being set multiple times!
if not chunk:
stdout, stderr = p.communicate()

View File

@ -859,7 +859,7 @@ def _preprocess_ports(module, values):
else:
port_binds = len(container_ports) * [(ipaddr,)]
else:
module.fail_json(
return module.fail_json(
msg=f'Invalid port description "{port}" - expected 1 to 3 colon-separated parts, but got {p_len}. '
"Maybe you forgot to use square brackets ([...]) around an IPv6 address?"
)

View File

@ -499,6 +499,8 @@ class ServicesManager(BaseComposeManager):
result = self.cmd_restart()
elif self.state == "absent":
result = self.cmd_down()
else:
raise AssertionError("Unexpected state")
result["containers"] = self.list_containers()
result["images"] = self.list_images()