{"record":{"id":"e8aade4bf7f2deb8","repo":"hsliuping/TradingAgents-CN","slug":"name","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"tradingagents/agents/__init__.py","lineNumber":53,"sourceCode":"    \"RiskDebateState\",\n    \"create_bear_researcher\",\n    \"create_bull_researcher\",\n    \"create_research_manager\",\n    \"create_fundamentals_analyst\",\n    \"create_market_analyst\",\n    \"create_neutral_debator\",\n    \"create_news_analyst\",\n    \"create_risky_debator\",\n    \"create_risk_manager\",\n    \"create_safe_debator\",\n    \"create_social_media_analyst\",\n    \"create_trader\",\n]\n\n\ndef __getattr__(name: str):\n    if name not in _EXPORTS:\n        raise AttributeError(name)\n\n    module_name, attr_name = _EXPORTS[name]\n    module = importlib.import_module(module_name)\n    value = getattr(module, attr_name)\n    globals()[name] = value\n    return value\n\n\ndef __dir__():\n    return sorted(set(globals().keys()) | set(_EXPORTS.keys()))\n","sourceCodeStart":35,"sourceCodeEnd":64,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/agents/__init__.py#L35-L64","documentation":"Raised by the module-level __getattr__ in tradingagents/agents/__init__.py when code accesses an attribute that is not in the lazy-export _EXPORTS mapping. The package uses PEP 562 lazy imports, so unknown attribute lookups surface as AttributeError(name) rather than the usual module attribute error.","triggerScenarios":"Calling e.g. tradingagents.agents.nonexistent or a typo like tradingagents.agents.create_tradr (not in _EXPORTS). Also `from tradingagents.agents import X` where X was never registered in the _EXPORTS dict.","commonSituations":"Typos in agent factory names, using an agent name that exists elsewhere in the codebase but was never added to _EXPORTS, or expecting old exports after a refactor to lazy loading.","solutions":["Check the _EXPORTS dict in tradingagents/agents/__init__.py for valid names","Fix the typo in the attribute/import name","If the symbol should be public, add it to _EXPORTS with its (module, attr) pair"],"exampleFix":"// before\nfrom tradingagents.agents import create_analyst\nagent = tradingagents.agents.create_tradr(...)\n// after\nfrom tradingagents.agents import create_trader\nagent = create_trader(...)","handlingStrategy":"validation","validationCode":"import tradingagents.agents as ta\nassert 'create_trader' in dir(ta) or True\n# authoritative check against the export map\nfrom tradingagents.agents import _EXPORTS\nif 'create_trader' not in _EXPORTS:\n    raise KeyError('create_trader is not exported; valid: %s' % sorted(_EXPORTS))","typeGuard":"def is_agent_export(name: str) -> bool:\n    from tradingagents.agents import _EXPORTS\n    return name in _EXPORTS","tryCatchPattern":"try:\n    create_trader = getattr(tradingagents.agents, 'create_trader')\nexcept AttributeError:\n    # surface valid options for debugging\n    raise","preventionTips":["Use an IDE so attribute names autocomplete against the lazy module","When adding agents, register them in _EXPORTS in the same PR","Pin export names in a smoke test that iterates _EXPORTS and getattr's each one"],"tags":["python","import","lazy-loading","attributeerror"],"backgroundTag":"attribute-not-found","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}