From c94f78e0b094abf584b749d96e851aa2b79267fc Mon Sep 17 00:00:00 2001 From: Harwinder Sekhon Date: Sun, 6 Sep 2026 16:46:15 -0400 Subject: [PATCH] chore: drop unused imports and a dead constant (no behaviour change) - backtest/diagnose_filters: unused BacktestConfig import - pair_signals/__init__: unused PlatformConfig import - scripts/shadow_scan: unused pandas import - research burst_precursors / calendar_impact / duka_spread: unused sys / COST / struct - test_all: MagicMock, StringIO, Colors and two function-local imports that nothing in the test bodies used - telegram_bot: ViolentWatch is only a type hint -> imported under TYPE_CHECKING compare_oanda_tiingo.py and oanda_td_divergence.py are left alone here because the hygiene commit deletes them. Suite: 464 passed, 0 failed (unchanged). Claude-Session: https://claude.ai/code/session_0156YhogLytzj9P2iH1skGbL --- backtest/diagnose_filters.py | 1 - backtest/research/burst_precursors.py | 2 +- backtest/research/calendar_impact.py | 2 +- backtest/research/duka_spread.py | 1 - pair_signals/__init__.py | 2 +- scripts/shadow_scan.py | 2 -- telegram_bot.py | 7 +++++-- test_all.py | 7 ++----- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/backtest/diagnose_filters.py b/backtest/diagnose_filters.py index 3b026c7..76593cf 100644 --- a/backtest/diagnose_filters.py +++ b/backtest/diagnose_filters.py @@ -45,7 +45,6 @@ from gpu_backtest import ( # noqa: E402 BAR_SECONDS, GPUTechnicalEngine, PAIR_ALIASES, - BacktestConfig, IndicatorCache, fetch_history, precompute_indicators, diff --git a/backtest/research/burst_precursors.py b/backtest/research/burst_precursors.py index 5fa541c..2669077 100644 --- a/backtest/research/burst_precursors.py +++ b/backtest/research/burst_precursors.py @@ -9,7 +9,7 @@ within/outside the scheduled-data hours, and an out-of-sample logistic model python backtest/research/burst_precursors.py PARQUET BAR_MINUTES [--k 3] [--start ... --end ...] """ -import argparse, sys +import argparse import numpy as np, pandas as pd diff --git a/backtest/research/calendar_impact.py b/backtest/research/calendar_impact.py index 6e99669..6ba339c 100644 --- a/backtest/research/calendar_impact.py +++ b/backtest/research/calendar_impact.py @@ -7,7 +7,7 @@ import argparse, sys from pathlib import Path import numpy as np, pandas as pd sys.path.insert(0, str(Path(__file__).resolve().parent)) -from open_trade_bursts import wilder_atr, simulate, r_of, stats, K, COST +from open_trade_bursts import wilder_atr, simulate, r_of, stats, K CAL = Path(__file__).resolve().parent.parent / "cache" / "calendar.parquet" diff --git a/backtest/research/duka_spread.py b/backtest/research/duka_spread.py index f5a29a9..12eddf5 100644 --- a/backtest/research/duka_spread.py +++ b/backtest/research/duka_spread.py @@ -10,7 +10,6 @@ bi5 format: LZMA 'alone' stream of 20-byte big-endian records XAUUSD prices scaled x1000. URL months are 0-indexed. """ import lzma -import struct import sys from concurrent.futures import ThreadPoolExecutor from datetime import date, timedelta diff --git a/pair_signals/__init__.py b/pair_signals/__init__.py index 13a4e48..1abc310 100644 --- a/pair_signals/__init__.py +++ b/pair_signals/__init__.py @@ -10,7 +10,7 @@ then register it in this file. from typing import Optional, List, Dict, Callable -from config import PlatformConfig, Timeframe +from config import Timeframe from signal_aggregator import SignalAggregator, SignalReport from providers import BaseDataProvider diff --git a/scripts/shadow_scan.py b/scripts/shadow_scan.py index f031a4c..516e15b 100644 --- a/scripts/shadow_scan.py +++ b/scripts/shadow_scan.py @@ -36,8 +36,6 @@ import time from datetime import datetime, timezone from pathlib import Path -import pandas as pd - sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from config import PlatformConfig, Timeframe, XAUUSD diff --git a/telegram_bot.py b/telegram_bot.py index 25015a2..ccd0aab 100755 --- a/telegram_bot.py +++ b/telegram_bot.py @@ -50,7 +50,7 @@ import threading import time from concurrent.futures import ThreadPoolExecutor from datetime import datetime, timezone -from typing import Any, Dict, List, Optional, Set +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update from telegram.constants import ParseMode @@ -77,7 +77,10 @@ from market_outlook import maybe_run_outlook from news_engine import FundamentalContext, NewsEngine from pair_signals import PAIR_PRODUCERS from signal_aggregator import SignalAggregator, SignalReport -from violent_watch import ViolentWatch, attach_watch, should_send_headsup +from violent_watch import attach_watch, should_send_headsup + +if TYPE_CHECKING: # type hints only — ViolentWatch is never needed at runtime here + from violent_watch import ViolentWatch _APP = get_app_config() diff --git a/test_all.py b/test_all.py index c9fdf8f..d94f8f6 100644 --- a/test_all.py +++ b/test_all.py @@ -12,8 +12,7 @@ import threading import tempfile import traceback from datetime import datetime, timedelta, timezone -from unittest.mock import patch, MagicMock -from io import StringIO +from unittest.mock import patch import numpy as np import pandas as pd @@ -1489,7 +1488,7 @@ print("\n═══ Module 6: main.py ═══") from main import ( signal_color, quality_color, _compact_reason, - report_to_dict, build_config, Colors, + report_to_dict, build_config, ) @@ -2777,7 +2776,6 @@ def _(): @test("CP: cp_patterns subset filter excludes disabled detectors") def _(): - from dataclasses import replace df = make_cp_df(double_bottom_closes()) cfg = XauStrategyConfig(cp_patterns=["bull_flag"]) assert detect_chart_pattern(df, atr=5.0, cfg=cfg) is None @@ -7757,7 +7755,6 @@ def _(): @test("signal_log: analyze_pair weekend early-return is logged") def _(): import signal_log as slog - from signal_aggregator import _is_forex_weekend fd, path = tempfile.mkstemp(suffix=".db") os.close(fd) os.remove(path)