{"record":{"id":"64d845e55272aa0e","repo":"hsliuping/TradingAgents-CN","slug":"configmanager-is-deprecated-and-will-be-removed-in","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"console","errorClass":"DeprecationWarning","httpStatus":null,"severity":"warning","filePath":"tradingagents/config/config_manager.py","lineNumber":24,"sourceCode":"⚠️ DEPRECATED: 此模块已废弃，将在 2026-03-31 后移除\n   请使用新的配置系统: app.services.config_service.ConfigService\n   迁移指南: docs/DEPRECATION_NOTICE.md\n   迁移脚本: scripts/migrate_config_to_db.py\n\"\"\"\n\nimport json\nimport os\nimport re\nimport warnings\nfrom datetime import datetime\nfrom zoneinfo import ZoneInfo\nfrom typing import Dict, List, Optional, Any\nfrom dataclasses import dataclass, asdict\nfrom pathlib import Path\nfrom dotenv import load_dotenv\n\n# 发出废弃警告\nwarnings.warn(\n    \"ConfigManager is deprecated and will be removed in version 2.0 (2026-03-31). \"\n    \"Please use app.services.config_service.ConfigService instead. \"\n    \"See docs/DEPRECATION_NOTICE.md for migration guide.\",\n    DeprecationWarning,\n    stacklevel=2\n)\n\n# 导入统一日志系统\nfrom tradingagents.utils.logging_init import get_logger\n\n# 导入日志模块\nfrom tradingagents.utils.logging_manager import get_logger\n# 运行时设置：读取系统时区\nfrom tradingagents.config.runtime_settings import get_timezone_name\nlogger = get_logger('agents')\n\n# 导入数据模型（避免循环导入）\nfrom .usage_models import UsageRecord, ModelConfig, PricingConfig","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/config/config_manager.py#L6-L42","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Follow docs/DEPRECATION_NOTICE.md and migrate from ConfigManager to app.services.config_service.ConfigService.","If migration must wait, suppress scoped: warnings.filterwarnings('ignore', message='ConfigManager is deprecated', category=DeprecationWarning) — never globally silence all DeprecationWarnings.","Schedule the migration before 2026-03-31 / version 2.0, after which the module is deleted."],"exampleFix":"# before\nfrom tradingagents.config.config_manager import ConfigManager\ncfg = ConfigManager()\n\n# after\nfrom app.services.config_service import ConfigService\ncfg = ConfigService()","handlingStrategy":"fallback","validationCode":"try:\n    from app.services.config_service import ConfigService  # preferred path\n    cfg = ConfigService()\nexcept ImportError:\n    import warnings\n    with warnings.catch_warnings():\n        warnings.filterwarnings(\"ignore\", message=\"ConfigManager is deprecated\", category=DeprecationWarning)\n        from tradingagents.config.config_manager import ConfigManager\n    cfg = ConfigManager()  # temporary fallback","typeGuard":"import warnings\n\ndef uses_deprecated_config_manager() -> bool:\n    \"\"\"Detect if the legacy module would trigger the deprecation warning.\"\"\"\n    return any(issubclass(w.category, DeprecationWarning) and \"ConfigManager is deprecated\" in str(w.message)\n               for w in warnings.catch_warnings(record=True) or []) if False else __import__(\"tradingagents.config.config_manager\", fromlist=[\"x\"]) is not None","tryCatchPattern":"import warnings\nwith warnings.catch_warnings():\n    warnings.filterwarnings(\"ignore\", message=\"ConfigManager is deprecated\", category=DeprecationWarning)\n    from tradingagents.config.config_manager import ConfigManager\n    cfg = ConfigManager()","preventionTips":["Migrate to ConfigService per docs/DEPRECATION_NOTICE.md before version 2.0 (2026-03-31).","Scope any warning suppression by message, never blanket-ignore DeprecationWarning in CI.","Add a recurring check for deprecated imports before each release."],"tags":["deprecation","config","migration","python-warnings"],"backgroundTag":"deprecation-warning","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}