{"record":{"id":"844f9c880fcb487d","repo":"pola-rs/polars","slug":"schema-overrides-should-be-of-type-list-or-dict-844f9c","errorCode":null,"errorMessage":"`schema_overrides` should be of type list or dict, got {qualified_type_name(schema_overrides)!r}","messagePattern":"`schema_overrides` should be of type list or dict, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/csv/functions.py","lineNumber":903,"sourceCode":"        issue_unstable_warning(msg)\n\n    credential_provider_builder = _init_credential_provider_builder(\n        credential_provider, source, storage_options, \"scan_csv\"\n    )\n    del credential_provider\n\n    dtype_list: list[tuple[str, PolarsDataType]] | None = None\n    dtype_slice: Sequence[PolarsDataType] | None = None\n    if schema_overrides is not None:\n        if isinstance(schema_overrides, dict):\n            dtype_list = []\n            for k, v in schema_overrides.items():\n                dtype_list.append((k, parse_into_dtype(v)))\n        elif isinstance(schema_overrides, Sequence):\n            dtype_slice = [parse_into_dtype(v) for v in schema_overrides]\n        else:\n            msg = f\"`schema_overrides` should be of type list or dict, got {qualified_type_name(schema_overrides)!r}\"\n            raise TypeError(msg)\n    processed_null_values = _process_null_values(null_values)\n\n    if isinstance(source, list):\n        sources = source\n        source = None  # type: ignore[assignment]\n    else:\n        sources = []\n\n    pylf = PyLazyFrame.new_from_csv(\n        source,\n        sources,\n        separator=separator,\n        has_header=has_header,\n        ignore_errors=ignore_errors,\n        skip_rows=skip_rows,\n        skip_lines=skip_lines,\n        n_rows=n_rows,\n        overwrite_dtype=dtype_list,","sourceCodeStart":885,"sourceCodeEnd":921,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/csv/functions.py#L885-L921","documentation":"Internally, after the initial validation, `scan_csv` normalizes `schema_overrides` entries via `parse_into_dtype`. If the argument survives the dict/Sequence isinstance checks but is neither — reaching this final else — polars raises this TypeError reporting the qualified type name of the offending value. It is a defensive, more detailed version of the earlier `schema_overrides` type error.","triggerScenarios":"Calling `pl.scan_csv` with a `schema_overrides` object that is not a dict or Sequence (e.g. a set, a custom mapping, a scalar dtype) reaching the normalization branch, typically via `_scan` forwarding.","commonSituations":"Custom dict-like classes not inheriting from dict; passing frozenset or numpy scalar types; dynamically constructed kwargs with wrong shapes.","solutions":["Convert the value to a plain dict or list before the call: `dict(schema_overrides)` or `list(...)`.","Ensure values inside the container are dtype-convertible (they are parsed with `parse_into_dtype`).","Add a pre-call assertion: `assert isinstance(so, (dict, list, tuple))`."],"exampleFix":"// before\npl.scan_csv(\"f.csv\", schema_overrides={\"a\", \"b\"})  # set\n// after\npl.scan_csv(\"f.csv\", schema_overrides=list(schema_overrides_set))","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_overrides_container(so) -> bool:\n    from collections.abc import Sequence\n    return isinstance(so, (dict, Sequence)) and not isinstance(so, (str, bytes, set))","tryCatchPattern":"try:\n    lf = pl.scan_csv(src, schema_overrides=so)\nexcept TypeError as e:\n    if \"schema_overrides\" in str(e):\n        lf = pl.scan_csv(src, schema_overrides=dict(so))\n    else:\n        raise","preventionTips":["Pass plain dict/list instances, not sets, frozensets, or custom mappings.","Convert numpy/generic container types to native Python before scanning.","Add an input-normalization layer for dynamically built kwargs."],"tags":["python","csv","lazy","type-error"],"backgroundTag":"type-mismatch","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"}