chore: make the whole tree ruff-clean, not just app/

CI only lints app/, so 11 findings had accumulated in tests/ and scripts/.

Mechanical and behaviour-neutral, but two were not auto-fixable and needed a
judgement call rather than `ruff --fix`:

- E741 in run_fip_breadth_diagnostics: `l` is the OHLCV low and is genuinely
  used, so this was a naming fix (`l` -> `lo`), not a deletion.
- F841 in the same file: `vol_ix`/`momr_ix` are assigned from a pure local
  `_index()` and never read, so removing them cannot change any output. Their
  upstream `vol_weeks`/`momr_weeks` maps *are* used further down and stay; the
  comment above `_index` was corrected to say so.

The rest are unused imports and f-strings without placeholders (literal
markdown table headers, so identical output).

Verified beyond the linter, since py_compile does not catch a removed-but-used
import: every removed symbol has zero remaining references, all scripts compile,
and the full unit suite passes (852 passed, 1 skipped).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-07 18:43:46 +02:00
co-authored by Claude Opus 5
parent 3483797e75
commit 1c6ccceb12
9 changed files with 9 additions and 17 deletions
-1
View File
@@ -31,7 +31,6 @@ if str(ROOT) not in sys.path:
from scripts.research_rankings import ( # noqa: E402 from scripts.research_rankings import ( # noqa: E402
_live_universe_rank_map, _live_universe_rank_map,
_period_percentiles,
) )
POLICY_NAMES = ( POLICY_NAMES = (
-1
View File
@@ -57,7 +57,6 @@ if str(ROOT) not in sys.path:
from scripts.research_rankings import ( # noqa: E402 from scripts.research_rankings import ( # noqa: E402
_live_universe_rank_map, _live_universe_rank_map,
_period_percentiles,
) )
# Must match Phase A cache when reusing research-cands.pkl # Must match Phase A cache when reusing research-cands.pkl
+6 -7
View File
@@ -162,13 +162,13 @@ def _load_job(conn, symbol: str, spy: dict) -> tuple | None:
if len(rows) < 90: if len(rows) < 90:
return None return None
ords, opens, highs, lows, closes, vols = [], [], [], [], [], [] ords, opens, highs, lows, closes, vols = [], [], [], [], [], []
for d, o, h, l, c, v in rows: for d, o, h, lo, c, v in rows:
if isinstance(d, str): if isinstance(d, str):
d = date.fromisoformat(d[:10]) d = date.fromisoformat(d[:10])
ords.append(d.toordinal()) ords.append(d.toordinal())
opens.append(float(o)) opens.append(float(o))
highs.append(float(h)) highs.append(float(h))
lows.append(float(l)) lows.append(float(lo))
closes.append(float(c)) closes.append(float(c))
vols.append(float(v or 0)) vols.append(float(v or 0))
return (symbol, ords, opens, highs, lows, closes, vols, spy) return (symbol, ords, opens, highs, lows, closes, vols, spy)
@@ -275,7 +275,8 @@ def main() -> None:
vol_weeks = collected.get("vol_6m") or {} vol_weeks = collected.get("vol_6m") or {}
momr_weeks = collected.get("mom_12_1_resid") or {} momr_weeks = collected.get("mom_12_1_resid") or {}
# Index mom/vol by (week, symbol) for joins # Index mom by (week, symbol) for joins. vol/momr are consumed as week maps
# directly further down, so they need no index.
def _index(weeks_map: dict) -> dict[tuple, dict]: def _index(weeks_map: dict) -> dict[tuple, dict]:
out: dict[tuple, dict] = {} out: dict[tuple, dict] = {}
for wk, recs in weeks_map.items(): for wk, recs in weeks_map.items():
@@ -290,8 +291,6 @@ def main() -> None:
return out return out
mom_ix = _index(mom_weeks) mom_ix = _index(mom_weeks)
vol_ix = _index(vol_weeks)
momr_ix = _index(momr_weeks)
# Per-week membership + extended checks via shared rich filter # Per-week membership + extended checks via shared rich filter
same_week: dict[tuple, list[tuple[float, float]]] = defaultdict(list) same_week: dict[tuple, list[tuple[float, float]]] = defaultdict(list)
@@ -606,8 +605,8 @@ def _update_md(path: Path, results: dict, artifact: Path) -> None:
"", "",
"### Authoritative unconditional fip (liquid top-N, post-mask)", "### Authoritative unconditional fip (liquid top-N, post-mask)",
"", "",
f"| metric | value |", "| metric | value |",
f"|---|---|", "|---|---|",
f"| mean_ic | {h.get('mean_ic')} |", f"| mean_ic | {h.get('mean_ic')} |",
f"| ic_t_stat | {h.get('ic_t_stat')} |", f"| ic_t_stat | {h.get('ic_t_stat')} |",
f"| weeks | {h.get('weeks')} |", f"| weeks | {h.get('weeks')} |",
+2 -2
View File
@@ -162,8 +162,8 @@ def _write_md(path: Path, payload: dict) -> None:
row = br.get("row") or br row = br.get("row") or br
if row: if row:
lines.extend([ lines.extend([
f"| metric | value |", "| metric | value |",
f"|---|---|", "|---|---|",
f"| mean_ic | {row.get('mean_ic')} |", f"| mean_ic | {row.get('mean_ic')} |",
f"| ic_t_stat | {row.get('ic_t_stat')} |", f"| ic_t_stat | {row.get('ic_t_stat')} |",
f"| ic_positive_pct | {row.get('ic_positive_pct')} |", f"| ic_positive_pct | {row.get('ic_positive_pct')} |",
-1
View File
@@ -26,7 +26,6 @@ import os
import pickle import pickle
import sys import sys
import time import time
from collections import defaultdict
from concurrent.futures import ProcessPoolExecutor from concurrent.futures import ProcessPoolExecutor
from datetime import date, datetime from datetime import date, datetime
from pathlib import Path from pathlib import Path
-1
View File
@@ -70,7 +70,6 @@ if str(ROOT) not in sys.path:
from scripts.research_rankings import ( # noqa: E402 from scripts.research_rankings import ( # noqa: E402
_live_universe_rank_map, _live_universe_rank_map,
_period_percentiles,
) )
CACHE_VERSION = "research-matrix-v1-daily-prod" CACHE_VERSION = "research-matrix-v1-daily-prod"
+1 -2
View File
@@ -2,9 +2,8 @@
from __future__ import annotations from __future__ import annotations
from datetime import datetime, timezone
from types import SimpleNamespace from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
@@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
import json
import sys import sys
from pathlib import Path from pathlib import Path
-1
View File
@@ -3,7 +3,6 @@ httpx transport (no network)."""
from __future__ import annotations from __future__ import annotations
import json
from datetime import date from datetime import date
import httpx import httpx