refactor(hermes_cli): compact docstrings (keep WHY/invariants); final AST-neutral layout pass

This commit is contained in:
Teknium
2026-09-02 21:49:33 -07:00
parent 52d8f0792c
commit 456377f704
8 changed files with 60 additions and 129 deletions
+4 -12
View File
@@ -7,12 +7,8 @@ import sqlite3
def add_column_if_missing(conn: sqlite3.Connection, table: str, column: str, ddl: str) -> bool:
"""``ALTER TABLE <table> ADD COLUMN <ddl>``, idempotent across races.
Returns True when this call added the column; swallows the ``duplicate column name`` error a
concurrent migrator may have caused. ``column`` is the human-readable name, ``ddl`` the
actual definition.
"""
"""``ALTER TABLE <table> ADD COLUMN <ddl>``, idempotent across races: True when this call added
it, False on the ``duplicate column name`` a concurrent migrator caused."""
try:
conn.execute(f"ALTER TABLE {table} ADD COLUMN {ddl}")
return True
@@ -24,12 +20,8 @@ def add_column_if_missing(conn: sqlite3.Connection, table: str, column: str, ddl
@contextlib.contextmanager
def write_txn(conn: sqlite3.Connection):
"""An IMMEDIATE write transaction: at most one concurrent writer wins.
The explicit ROLLBACK is guarded so a SQLite auto-rollback (no active transaction left under EIO
/ lock contention / corruption) cannot shadow the original exception with a spurious rollback
error.
"""
"""An IMMEDIATE write transaction. The explicit ROLLBACK is guarded so a SQLite auto-rollback
(no transaction left under EIO / contention / corruption) cannot shadow the original error."""
conn.execute("BEGIN IMMEDIATE")
try:
yield conn