Formatting and linting

This commit is contained in:
Jack Kingsman
2026-04-01 21:39:59 -07:00
parent 35265d8ae8
commit 80c6cc44e5
3 changed files with 23 additions and 17 deletions
+2 -8
View File
@@ -2971,9 +2971,7 @@ async def _migrate_049_foreign_key_cascade(conn: aiosqlite.Connection) -> None:
logger.info("Database backed up to %s before FK migration", backup_path)
# --- Phase 1: clean orphans (guard each table's existence) ---
tables_cursor = await conn.execute(
"SELECT name FROM sqlite_master WHERE type='table'"
)
tables_cursor = await conn.execute("SELECT name FROM sqlite_master WHERE type='table'")
existing_tables = {row[0] for row in await tables_cursor.fetchall()}
if "contact_advert_paths" in existing_tables and "contacts" in existing_tables:
@@ -3021,9 +3019,7 @@ async def _migrate_049_foreign_key_cascade(conn: aiosqlite.Connection) -> None:
if "payload_hash" in old_cols:
new_col_defs.append("payload_hash BLOB")
copy_cols.append("payload_hash")
new_col_defs.append(
"FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE SET NULL"
)
new_col_defs.append("FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE SET NULL")
cols_sql = ", ".join(new_col_defs)
copy_sql = ", ".join(copy_cols)
@@ -3103,5 +3099,3 @@ async def _migrate_049_foreign_key_cascade(conn: aiosqlite.Connection) -> None:
)
await conn.commit()
logger.debug("Rebuilt contact_name_history with ON DELETE CASCADE")
+1 -1
View File
@@ -26,7 +26,7 @@ echo -e "${YELLOW}=== Phase 1: Lint & Format ===${NC}"
echo -ne "${BLUE}[backend lint]${NC} "
cd "$REPO_ROOT"
uv run ruff check app/ tests/ --fix --quiet
uv run ruff format app/ tests/ --check --quiet
uv run ruff format app/ tests/ --quiet
echo -e "${GREEN}Passed!${NC}"
echo -ne "${BLUE}[frontend lint]${NC} "
+20 -8
View File
@@ -1199,12 +1199,18 @@ class TestRawPacketRepository:
"""Purge linked raw packets removes only rows with a message_id."""
ts = int(time.time())
msg_id_1 = await MessageRepository.create(
msg_type="PRIV", conversation_key="k1", text="t1",
sender_timestamp=ts, received_at=ts,
msg_type="PRIV",
conversation_key="k1",
text="t1",
sender_timestamp=ts,
received_at=ts,
)
msg_id_2 = await MessageRepository.create(
msg_type="PRIV", conversation_key="k2", text="t2",
sender_timestamp=ts, received_at=ts,
msg_type="PRIV",
conversation_key="k2",
text="t2",
sender_timestamp=ts,
received_at=ts,
)
linked_1, _ = await RawPacketRepository.create(b"\x01\x02\x03", ts)
linked_2, _ = await RawPacketRepository.create(b"\x04\x05\x06", ts)
@@ -1248,12 +1254,18 @@ class TestMaintenanceEndpoint:
ts = int(time.time())
msg_id_1 = await MessageRepository.create(
msg_type="PRIV", conversation_key="k1", text="t1",
sender_timestamp=ts, received_at=ts,
msg_type="PRIV",
conversation_key="k1",
text="t1",
sender_timestamp=ts,
received_at=ts,
)
msg_id_2 = await MessageRepository.create(
msg_type="PRIV", conversation_key="k2", text="t2",
sender_timestamp=ts, received_at=ts,
msg_type="PRIV",
conversation_key="k2",
text="t2",
sender_timestamp=ts,
received_at=ts,
)
linked_1, _ = await RawPacketRepository.create(b"\x0a\x0b\x0c", ts)
linked_2, _ = await RawPacketRepository.create(b"\x0d\x0e\x0f", ts)