{"record":{"id":"aaaa22bad82b66df","repo":"cocoindex-io/cocoindex","slug":"module-name-r-has-no-attribute-name-r","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/ops/code.py","lineNumber":338,"sourceCode":"\ndef __getattr__(name: str) -> _typing.Any:\n    # Deprecated alias for the removed ``CodeAst`` class, so annotations and\n    # ``isinstance`` checks in older callers keep working. ``CodeSource`` is\n    # the single handle now; note its constructor is lazy and tolerant where\n    # ``CodeAst``'s was eager and raising, and the old ``.matches`` / ``.split``\n    # / ``.index_terms`` methods live on the consumers instead\n    # (``CodePattern.match_source`` / ``match_code``, ``RecursiveSplitter.split``,\n    # ``index_terms``).\n    if name == \"CodeAst\":\n        _warnings.warn(\n            \"CodeAst is deprecated and now aliases CodeSource; use CodeSource \"\n            \"with CodePattern.match_source / match_code, RecursiveSplitter.split, \"\n            \"and index_terms\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        return CodeSource\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":320,"sourceCodeEnd":339,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/ops/code.py#L320-L339","documentation":"The cocoindex.ops.code module defines module-level __getattr__ for backward-compatible aliases (e.g. CodeSource). Accessing any other attribute not defined in the module raises a plain AttributeError naming the missing attribute.","triggerScenarios":"from cocoindex.ops.code import SomeSymbol where SomeSymbol was removed/renamed (e.g. an old splitter or pattern API that moved to CodePattern.match_source / RecursiveSplitter.split).","commonSituations":"Upgrading cocoindex after the v1 redesign; following outdated docs/examples that reference removed symbols; IDE auto-imports picking the wrong module.","solutions":["Use the current APIs: CodePattern.match_source / match_code, RecursiveSplitter.split, or index_terms.","Import CodeSource for the deprecated code-source entry point (emits a DeprecationWarning).","Check the module's actual exports with dir(cocoindex.ops.code) or the docs."],"exampleFix":"// before\nfrom cocoindex.ops.code import CodeSplitter\n// after\nfrom cocoindex.ops import RecursiveSplitter\nsplitter = RecursiveSplitter()","handlingStrategy":"try-catch","validationCode":"import cocoindex.ops.code as c\nassert hasattr(c, \"SymbolToUse\"), \"symbol removed; check current API\"","typeGuard":null,"tryCatchPattern":"try:\n    from cocoindex.ops.code import CodeSplitter\nexcept (ImportError, AttributeError):\n    from cocoindex.ops import RecursiveSplitter\n    CodeSplitter = RecursiveSplitter","preventionTips":["Pin cocoindex versions in requirements to avoid surprise removals.","Follow the migration notes for the v1 API when upgrading.","Use the documented current APIs (CodePattern, RecursiveSplitter) in new code."],"tags":["python","attributeerror","deprecated-api","module"],"backgroundTag":"deprecated-api-usage","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}