From b9b4600cb24c1698296bb103c71bdd88dba083ae Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 3 Sep 2026 00:03:41 -0700 Subject: [PATCH] refactor(hermes_cli): lost_and_found attempt record built in one literal --- hermes_cli/session_lost_and_found.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hermes_cli/session_lost_and_found.py b/hermes_cli/session_lost_and_found.py index 70da53ac59..031eb98d70 100644 --- a/hermes_cli/session_lost_and_found.py +++ b/hermes_cli/session_lost_and_found.py @@ -103,14 +103,13 @@ def run_cli_lost_and_found_recover( dump.kill() load.kill() raise LostAndFoundError(f"sqlite3 .recover timed out after {timeout:.0f}s") - attempt = { + attempts.append({ "command": command, "dump_returncode": dump.returncode, "load_returncode": load.returncode, "dump_stderr_tail": dump_err.decode("utf-8", "replace")[-2000:], "load_stderr_tail": load_err.decode("utf-8", "replace")[-2000:], - } - attempts.append(attempt) - attempt["usable"] = _lost_and_found_db_usable(lf_path) - if attempt["usable"]: + "usable": _lost_and_found_db_usable(lf_path), + }) + if attempts[-1]["usable"]: return {"binary": sqlite3_bin, "attempts": attempts} details = "; ".join( f"[{a['command']}] dump rc={a['dump_returncode']} load rc={a['load_returncode']} " @@ -257,10 +256,8 @@ def map_lost_and_found_rows(lf_conn: sqlite3.Connection, dest: sqlite3.Connectio defaults.pop(index, None) targets[kind_name] = (_table_columns(dest, kind_name), defaults) lf_tables = [ - str(row[0]) - for row in lf_conn.execute( - "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lost_and_found%'" - ) + str(row[0]) for row in + lf_conn.execute("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'lost_and_found%'") ] report["lost_and_found_tables"] = lf_tables for lf_table in lf_tables: