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-member,
no-name-in-module, no-name-in-module,
not-an-iterable, not-an-iterable,
possibly-used-before-assignment,
protected-access, protected-access,
raise-missing-from, raise-missing-from,
redefined-outer-name, # needed for test fixtures redefined-outer-name, # needed for test fixtures

View File

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

View File

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

View File

@ -859,7 +859,7 @@ def _preprocess_ports(module, values):
else: else:
port_binds = len(container_ports) * [(ipaddr,)] port_binds = len(container_ports) * [(ipaddr,)]
else: 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}. ' 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?" "Maybe you forgot to use square brackets ([...]) around an IPv6 address?"
) )

View File

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