From 1c6ccceb12026ddb5b6d5ba794cd18917d199980 Mon Sep 17 00:00:00 2001 From: Dennis Thiessen Date: Fri, 7 Aug 2026 18:43:46 +0200 Subject: [PATCH] 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 --- scripts/run_daily_reentry_matrix.py | 1 - scripts/run_execution_recovery_matrix.py | 1 - scripts/run_fip_breadth_diagnostics.py | 13 ++++++------- scripts/run_fip_breadth_research.py | 4 ++-- scripts/run_prod_book_universe_matrix.py | 1 - scripts/run_research_matrix.py | 1 - tests/unit/test_openai_sentiment_provider.py | 3 +-- tests/unit/test_research_snapshot_manifest.py | 1 - tests/unit/test_sec_client.py | 1 - 9 files changed, 9 insertions(+), 17 deletions(-) diff --git a/scripts/run_daily_reentry_matrix.py b/scripts/run_daily_reentry_matrix.py index f71f79e..7b2d6ce 100644 --- a/scripts/run_daily_reentry_matrix.py +++ b/scripts/run_daily_reentry_matrix.py @@ -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 = ( diff --git a/scripts/run_execution_recovery_matrix.py b/scripts/run_execution_recovery_matrix.py index 07abdfa..6c3f615 100644 --- a/scripts/run_execution_recovery_matrix.py +++ b/scripts/run_execution_recovery_matrix.py @@ -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 diff --git a/scripts/run_fip_breadth_diagnostics.py b/scripts/run_fip_breadth_diagnostics.py index 3c55376..e5e17d3 100644 --- a/scripts/run_fip_breadth_diagnostics.py +++ b/scripts/run_fip_breadth_diagnostics.py @@ -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')} |", diff --git a/scripts/run_fip_breadth_research.py b/scripts/run_fip_breadth_research.py index 9b0e57a..a20c7ff 100644 --- a/scripts/run_fip_breadth_research.py +++ b/scripts/run_fip_breadth_research.py @@ -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')} |", diff --git a/scripts/run_prod_book_universe_matrix.py b/scripts/run_prod_book_universe_matrix.py index 6d5b9cc..cc53b2d 100644 --- a/scripts/run_prod_book_universe_matrix.py +++ b/scripts/run_prod_book_universe_matrix.py @@ -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 diff --git a/scripts/run_research_matrix.py b/scripts/run_research_matrix.py index d771a4b..f16c121 100644 --- a/scripts/run_research_matrix.py +++ b/scripts/run_research_matrix.py @@ -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" diff --git a/tests/unit/test_openai_sentiment_provider.py b/tests/unit/test_openai_sentiment_provider.py index 262c75a..877fd5e 100644 --- a/tests/unit/test_openai_sentiment_provider.py +++ b/tests/unit/test_openai_sentiment_provider.py @@ -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 diff --git a/tests/unit/test_research_snapshot_manifest.py b/tests/unit/test_research_snapshot_manifest.py index 6205167..4232998 100644 --- a/tests/unit/test_research_snapshot_manifest.py +++ b/tests/unit/test_research_snapshot_manifest.py @@ -2,7 +2,6 @@ from __future__ import annotations -import json import sys from pathlib import Path diff --git a/tests/unit/test_sec_client.py b/tests/unit/test_sec_client.py index 31a82d7..80704c9 100644 --- a/tests/unit/test_sec_client.py +++ b/tests/unit/test_sec_client.py @@ -3,7 +3,6 @@ httpx transport (no network).""" from __future__ import annotations -import json from datetime import date import httpx