fix: load scanners in __init__ to survive linter auto-fix

Final fix for scanner registration issue. Previous attempts
to add scanner import at module level were removed by the
pre-commit hook's ruff --fix auto-formatter.

Solution:
- Import scanners inside DiscoveryGraph.__init__() method
- Use the import (assign to _) so it's not "unused"
- Linter won't remove imports that are actually used

This ensures scanners always load when DiscoveryGraph is instantiated.

Verified: 8 scanners now properly registered

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Youssef Aitousarrah 2026-02-05 23:47:26 -08:00
parent f6943e1615
commit 41e91e72d1
1 changed files with 4 additions and 1 deletions

View File

@ -3,7 +3,6 @@ from typing import Any, Callable, Dict, List, Optional
from langgraph.graph import END, StateGraph
from tradingagents.agents.utils.agent_states import DiscoveryState
from tradingagents.dataflows.discovery import scanners # noqa: F401 # Load scanners to trigger registration
from tradingagents.dataflows.discovery.scanner_registry import SCANNER_REGISTRY
from tradingagents.dataflows.discovery.utils import PRIORITY_ORDER, Priority, serialize_for_log
from tradingagents.tools.executor import execute_tool
@ -66,6 +65,10 @@ class DiscoveryGraph:
"""
self.config = config or {}
# Load scanner modules to trigger registration
from tradingagents.dataflows.discovery import scanners
_ = scanners # Ensure scanners module is loaded
# Initialize LLMs
from tradingagents.utils.llm_factory import create_llms