{"record":{"id":"00949e2da40f89e4","repo":"pola-rs/polars","slug":"accessing-name-from-the-top-level-polars-module-was","errorCode":null,"errorMessage":"accessing `{name}` from the top-level `polars` module was deprecated in version 1.0.0. Import it directly from the `polars.exceptions` module instead, e.g.: `from polars.exceptions import {name}`","messagePattern":"accessing `(.+?)` from the top-level `polars` module was deprecated in version 1\\.0\\.0\\. Import it directly from the `polars\\.exceptions` module instead, e\\.g\\.: `from polars\\.exceptions import (.+?)`","errorType":"exception","errorClass":"AttributeRemovedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/__init__.py","lineNumber":533,"sourceCode":"\n    # This causes typechecking to resolve any Polars module attribute\n    # as Any regardless of existence so we check for TYPE_CHECKING, see #24334.\n    def __getattr__(name: str) -> Any:\n        # Backwards compatibility for plugins. This used to be called `polars.polars`,\n        # but is now `polars._plr`.\n        if name == \"polars\":\n            return plr\n        elif name == \"_allocator\":\n            return plr._allocator\n\n        # Deprecate re-export of exceptions at top-level\n        if name in dir(exceptions):\n            msg = (\n                f\"accessing `{name}` from the top-level `polars` module was deprecated \"\n                \"in version 1.0.0. Import it directly from the `polars.exceptions` module \"\n                f\"instead, e.g.: `from polars.exceptions import {name}`\"\n            )\n            raise exceptions.AttributeRemovedError(msg)\n\n        # Deprecate data type groups at top-level\n        import polars.datatypes.group as dtgroup\n\n        if name in dir(dtgroup):\n            msg = (\n                f\"`{name}` was deprecated in version 1.0.0. Define your own data type groups or \"\n                \"use the `polars.selectors` module for selecting columns of a certain data type.\"\n            )\n            raise exceptions.AttributeRemovedError(msg)\n\n        # Functions removed in 2.0\n        removed = {\n            \"arctan2d\": \"use `arctan2` followed by `.degrees()` instead.\",\n            \"groups\": \"use `df.with_row_index().group_by(...).agg(pl.col('index'))` instead.\",\n            \"read_csv_batched\": \"use `scan_csv` instead, in conjunction with `LazyFrame.collect(engine='streaming')`.\",\n            \"threadpool_size\": \"it was renamed; use `thread_pool_size` instead.\",\n        }","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/__init__.py#L515-L551","documentation":"Accessing an exception class (e.g. `polars.ComputeError`) from the top-level `polars` module triggers `__getattr__`, which raises `AttributeRemovedError` because exception classes were moved to `polars.exceptions` in version 1.0.0. The library no longer re-exports exceptions at top level and directs you to import them from their new home. This is a hard deprecation removal, not a soft warning.","triggerScenarios":"Any `polars.<ExceptionName>` attribute access where the name exists in `polars.exceptions`, e.g. `except polars.ShapeError:` or `polars.NoDataError`, after upgrading to polars >= 1.0.0.","commonSituations":"Upgrading from polars <1.0 to >=1.0 with old exception-handling code; copying older tutorials or StackOverflow snippets that catch `polars.ComputeError`; IDE auto-imports inserting `polars.SomeError` references.","solutions":["Replace `polars.<Name>` with `polars.exceptions.<Name>` in the expression that raised.","Change the import at the top of the file: `from polars.exceptions import <Name>` and reference the bare name.","Run a project-wide search for `polars\\.[A-Z]` and fix all exception-class references at once."],"exampleFix":"// before\nexcept polars.ComputeError as e:\n    ...\n\n// after\nfrom polars.exceptions import ComputeError\nexcept ComputeError as e:\n    ...","handlingStrategy":"type-guard","validationCode":"import polars.exceptions as plex\nassert hasattr(plex, 'ComputeError')","typeGuard":"def is_polars_exception(name: str) -> bool:\n    import polars.exceptions as plex\n    return hasattr(plex, name)","tryCatchPattern":"try:\n    err_cls = getattr(polars, 'ComputeError')\nexcept AttributeError:\n    from polars.exceptions import ComputeError as err_cls","preventionTips":["Always import exceptions from `polars.exceptions` in new code.","Run ruff/mypy with up-to-date polars stubs to catch removed top-level names.","Pin and read the polars 1.0.0 upgrade guide before upgrading."],"tags":["python","polars","deprecation","exceptions","module-attribute"],"backgroundTag":"deprecated-api-usage","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}