S101: fix

This commit is contained in:
Jörg Thalheim
2025-08-25 12:26:00 +02:00
parent 332d10e306
commit 6a2dfb8176
8 changed files with 38 additions and 15 deletions

View File

@@ -223,7 +223,9 @@ def construct_value(
# If the field is another dataclass
# Field_value must be a dictionary
if is_dataclass(t) and isinstance(field_value, dict):
assert isinstance(t, type)
if not isinstance(t, type):
msg = f"Expected a type, got {t}"
raise ClanError(msg)
return construct_dataclass(t, field_value)
# If the field expects a path

View File

@@ -281,7 +281,9 @@ class AsyncRuntime:
for name, task in self.tasks.items():
if task.finished and task.async_opts.check:
assert task.result is not None
if task.result is None:
msg = f"Task {name} finished but has no result"
raise ClanError(msg)
error = task.result.error
if error is not None:
if log.isEnabledFor(logging.DEBUG):

View File

@@ -16,7 +16,9 @@ def list_log_days() -> list[str]:
AssertionError: If LOG_MANAGER_INSTANCE is not initialized.
"""
assert LOG_MANAGER_INSTANCE is not None
if LOG_MANAGER_INSTANCE is None:
msg = "LOG_MANAGER_INSTANCE is not initialized"
raise ClanError(msg)
return [day.date_day for day in LOG_MANAGER_INSTANCE.list_log_days()]
@@ -38,7 +40,9 @@ def list_log_groups(
AssertionError: If LOG_MANAGER_INSTANCE is not initialized.
"""
assert LOG_MANAGER_INSTANCE is not None
if LOG_MANAGER_INSTANCE is None:
msg = "LOG_MANAGER_INSTANCE is not initialized"
raise ClanError(msg)
return LOG_MANAGER_INSTANCE.filter(selector, date_day=date_day)
@@ -63,7 +67,9 @@ def get_log_file(
AssertionError: If LOG_MANAGER_INSTANCE is not initialized.
"""
assert LOG_MANAGER_INSTANCE is not None
if LOG_MANAGER_INSTANCE is None:
msg = "LOG_MANAGER_INSTANCE is not initialized"
raise ClanError(msg)
log_file = LOG_MANAGER_INSTANCE.get_log_file(
op_key=id_key,

View File

@@ -74,7 +74,9 @@ class SudoAskpassProxy:
def _process(self, ssh_process: subprocess.Popen) -> None:
"""Execute the remote command with password proxying"""
# Monitor SSH output for password requests
assert ssh_process.stdout is not None, "SSH process stdout is None"
if ssh_process.stdout is None:
msg = "SSH process stdout is None"
raise ClanError(msg)
try:
for line in ssh_process.stdout:
line = line.strip()
@@ -137,10 +139,10 @@ class SudoAskpassProxy:
pass
# Unclear why we have to close this manually, but pytest reports unclosed fd
assert self.ssh_process.stdout is not None
self.ssh_process.stdout.close()
assert self.ssh_process.stdin is not None
self.ssh_process.stdin.close()
if self.ssh_process.stdout is not None:
self.ssh_process.stdout.close()
if self.ssh_process.stdin is not None:
self.ssh_process.stdin.close()
self.ssh_process = None
if self.thread:
self.thread.join()