{"id":"bb1b33b1ae2bcc18","repo":"python-poetry/poetry","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":"src/poetry/utils/helpers.py","lineNumber":352,"sourceCode":"_DEPRECATED_DOWNLOAD_EXPORTS = {\n    \"Downloader\",\n    \"download_file\",\n    \"HTTPRangeRequestSupportedError\",\n}\n\n\ndef __getattr__(name: str) -> object:\n    if name in _DEPRECATED_DOWNLOAD_EXPORTS:\n        warnings.warn(\n            f\"Importing `{name}` from `poetry.utils.helpers` is deprecated;\"\n            f\" use `poetry.utils.download.{name}` instead.\",\n            DeprecationWarning,\n            stacklevel=2,\n        )\n        from poetry.utils import download\n\n        return getattr(download, name)\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":334,"sourceCodeEnd":353,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/utils/helpers.py#L334-L353","documentation":"poetry.utils.helpers defines a module-level __getattr__. Names listed in _DEPRECATED_DOWNLOAD_EXPORTS (Downloader, download_file, HTTPRangeRequestSupportedError) are redirected to poetry.utils.download with a DeprecationWarning. Any other missing attribute triggers a standard AttributeError with this message. So the message only appears for genuinely non-existent names; the deprecated trio redirects silently (modulo the warning).","triggerScenarios":"Accessing an attribute that does not exist on poetry.utils.helpers, e.g. `from poetry.utils.helpers import download_file_renamed` or `poetry.utils.helpers.some_helper`, OR a star-import/typo referencing a removed symbol. The deprecated download symbols do NOT raise this — they warn and redirect.","commonSituations":"A typo in an import; relying on a helper that was relocated (e.g. download utilities moved to poetry.utils.download); code written against an older Poetry version expecting a symbol that no longer exists.","solutions":["For download-related symbols, import from poetry.utils.download instead of poetry.utils.helpers.","Search the codebase (`grep -r <name> src/poetry`) to find the symbol's current module.","Fix typos in the attribute/import name.","Pin or upgrade Poetry to a version where the symbol exists if it was removed."],"exampleFix":"# before\nfrom poetry.utils.helpers import download_file  # works but deprecated\nfrom poetry.utils.helpers import DownloaderXyz    # raises AttributeError\n# after\nfrom poetry.utils.download import download_file, Downloader","handlingStrategy":"type-guard","validationCode":"import poetry.utils.helpers as h\n\nname = 'download_file'  # attribute you intend to use\nif name in h._DEPRECATED_DOWNLOAD_EXPORTS:\n    # redirect target exists (will emit DeprecationWarning)\n    pass\nelif not hasattr(h, name):\n    raise AttributeError(f'helpers has no attribute {name!r}')","typeGuard":"import poetry.utils.helpers as h\n\ndef is_helpers_attr(name: str) -> bool:\n    return name in h._DEPRECATED_DOWNLOAD_EXPORTS or hasattr(h, name)","tryCatchPattern":"import poetry.utils.helpers as h\ntry:\n    val = getattr(h, name)\nexcept AttributeError:\n    # import from the correct module instead, e.g. poetry.utils.download\n    raise","preventionTips":["Import download utilities from poetry.utils.download, not helpers.","Pin Poetry to a known version and grep for symbol locations before relying on them.","Avoid star-imports so missing names surface at lint time."],"tags":["import","deprecation","attribute-error","refactoring"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}