hsliuping/TradingAgents-CN · warning · DeprecationWarning

ConfigManager is deprecated and will be removed in version 2

Error message

ConfigManager is deprecated and will be removed in version 2.0 (2026-03-31). Please use app.services.config_service.ConfigService instead. See docs/DEPRECATION_NOTICE.md for migration guide.

What it means

This is a DeprecationWarning emitted at import time of tradingagents.config.config_manager, announcing that ConfigManager will be removed in version 2.0 (2026-03-31) in favor of app.services.config_service.ConfigService. It fires simply by importing the module (module-level warnings.warn), so any transitive import surfaces it. Nothing is broken yet — it is a migration notice with a guide at docs/DEPRECATION_NOTICE.md.

Source

Thrown at tradingagents/config/config_manager.py:24

⚠️ DEPRECATED: 此模块已废弃,将在 2026-03-31 后移除
   请使用新的配置系统: app.services.config_service.ConfigService
   迁移指南: docs/DEPRECATION_NOTICE.md
   迁移脚本: scripts/migrate_config_to_db.py
"""

import json
import os
import re
import warnings
from datetime import datetime
from zoneinfo import ZoneInfo
from typing import Dict, List, Optional, Any
from dataclasses import dataclass, asdict
from pathlib import Path
from dotenv import load_dotenv

# 发出废弃警告
warnings.warn(
    "ConfigManager is deprecated and will be removed in version 2.0 (2026-03-31). "
    "Please use app.services.config_service.ConfigService instead. "
    "See docs/DEPRECATION_NOTICE.md for migration guide.",
    DeprecationWarning,
    stacklevel=2
)

# 导入统一日志系统
from tradingagents.utils.logging_init import get_logger

# 导入日志模块
from tradingagents.utils.logging_manager import get_logger
# 运行时设置:读取系统时区
from tradingagents.config.runtime_settings import get_timezone_name
logger = get_logger('agents')

# 导入数据模型(避免循环导入)
from .usage_models import UsageRecord, ModelConfig, PricingConfig

View on GitHub (pinned to 74783e8817)

Solutions

  1. Follow docs/DEPRECATION_NOTICE.md and migrate from ConfigManager to app.services.config_service.ConfigService.
  2. If migration must wait, suppress scoped: warnings.filterwarnings('ignore', message='ConfigManager is deprecated', category=DeprecationWarning) — never globally silence all DeprecationWarnings.
  3. Schedule the migration before 2026-03-31 / version 2.0, after which the module is deleted.

Example fix

# before
from tradingagents.config.config_manager import ConfigManager
cfg = ConfigManager()

# after
from app.services.config_service import ConfigService
cfg = ConfigService()
Defensive patterns

Strategy: fallback

Validate before calling

try:
    from app.services.config_service import ConfigService  # preferred path
    cfg = ConfigService()
except ImportError:
    import warnings
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", message="ConfigManager is deprecated", category=DeprecationWarning)
        from tradingagents.config.config_manager import ConfigManager
    cfg = ConfigManager()  # temporary fallback

Type guard

import warnings

def uses_deprecated_config_manager() -> bool:
    """Detect if the legacy module would trigger the deprecation warning."""
    return any(issubclass(w.category, DeprecationWarning) and "ConfigManager is deprecated" in str(w.message)
               for w in warnings.catch_warnings(record=True) or []) if False else __import__("tradingagents.config.config_manager", fromlist=["x"]) is not None

Try / catch

import warnings
with warnings.catch_warnings():
    warnings.filterwarnings("ignore", message="ConfigManager is deprecated", category=DeprecationWarning)
    from tradingagents.config.config_manager import ConfigManager
    cfg = ConfigManager()

Prevention

When it happens

Trigger: Any `from tradingagents.config.config_manager import ConfigManager` (directly or transitively) in a test run, notebook, or app startup. Warnings become highly visible when running pytest with -W error, filters=all, or under CI configured to escalate DeprecationWarning to errors.

Common situations: Upgrading the package and seeing new warnings in CI; test suites configured with -W error::DeprecationWarning; lingering legacy code paths that still construct ConfigManager while new code uses ConfigService; the removal date (2026-03-31) passing and imports starting to fail outright.

Related errors


AI-assisted analysis of hsliuping/TradingAgents-CN@74783e8817 (2026-08-28). Data as JSON: /api/errors/64d845e55272aa0e. Report an issue: GitHub.