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:
@@ -31,7 +31,6 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from scripts.research_rankings import ( # noqa: E402
|
||||
_live_universe_rank_map,
|
||||
_period_percentiles,
|
||||
)
|
||||
|
||||
POLICY_NAMES = (
|
||||
|
||||
@@ -57,7 +57,6 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from scripts.research_rankings import ( # noqa: E402
|
||||
_live_universe_rank_map,
|
||||
_period_percentiles,
|
||||
)
|
||||
|
||||
# Must match Phase A cache when reusing research-cands.pkl
|
||||
|
||||
@@ -162,13 +162,13 @@ def _load_job(conn, symbol: str, spy: dict) -> tuple | None:
|
||||
if len(rows) < 90:
|
||||
return None
|
||||
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):
|
||||
d = date.fromisoformat(d[:10])
|
||||
ords.append(d.toordinal())
|
||||
opens.append(float(o))
|
||||
highs.append(float(h))
|
||||
lows.append(float(l))
|
||||
lows.append(float(lo))
|
||||
closes.append(float(c))
|
||||
vols.append(float(v or 0))
|
||||
return (symbol, ords, opens, highs, lows, closes, vols, spy)
|
||||
@@ -275,7 +275,8 @@ def main() -> None:
|
||||
vol_weeks = collected.get("vol_6m") 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]:
|
||||
out: dict[tuple, dict] = {}
|
||||
for wk, recs in weeks_map.items():
|
||||
@@ -290,8 +291,6 @@ def main() -> None:
|
||||
return out
|
||||
|
||||
mom_ix = _index(mom_weeks)
|
||||
vol_ix = _index(vol_weeks)
|
||||
momr_ix = _index(momr_weeks)
|
||||
|
||||
# Per-week membership + extended checks via shared rich filter
|
||||
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)",
|
||||
"",
|
||||
f"| metric | value |",
|
||||
f"|---|---|",
|
||||
"| metric | value |",
|
||||
"|---|---|",
|
||||
f"| mean_ic | {h.get('mean_ic')} |",
|
||||
f"| ic_t_stat | {h.get('ic_t_stat')} |",
|
||||
f"| weeks | {h.get('weeks')} |",
|
||||
|
||||
@@ -162,8 +162,8 @@ def _write_md(path: Path, payload: dict) -> None:
|
||||
row = br.get("row") or br
|
||||
if row:
|
||||
lines.extend([
|
||||
f"| metric | value |",
|
||||
f"|---|---|",
|
||||
"| metric | value |",
|
||||
"|---|---|",
|
||||
f"| mean_ic | {row.get('mean_ic')} |",
|
||||
f"| ic_t_stat | {row.get('ic_t_stat')} |",
|
||||
f"| ic_positive_pct | {row.get('ic_positive_pct')} |",
|
||||
|
||||
@@ -26,7 +26,6 @@ import os
|
||||
import pickle
|
||||
import sys
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
from datetime import date, datetime
|
||||
from pathlib import Path
|
||||
|
||||
@@ -70,7 +70,6 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from scripts.research_rankings import ( # noqa: E402
|
||||
_live_universe_rank_map,
|
||||
_period_percentiles,
|
||||
)
|
||||
|
||||
CACHE_VERSION = "research-matrix-v1-daily-prod"
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ httpx transport (no network)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import date
|
||||
|
||||
import httpx
|
||||
|
||||
Reference in New Issue
Block a user