{"record":{"id":"35710aa11fb6ea8f","repo":"pola-rs/polars","slug":"schema-overrides-should-be-of-type-list-or-dict","errorCode":null,"errorMessage":"`schema_overrides` should be of type list or dict","messagePattern":"`schema_overrides` should be of type list or dict","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/csv/functions.py","lineNumber":377,"sourceCode":"    _check_arg_is_1byte(\"quote_char\", quote_char, can_be_empty=True)\n    _check_arg_is_1byte(\"eol_char\", eol_char, can_be_empty=False)\n\n    storage_options = storage_options or {}\n\n    if column_names and not has_header:\n        for column in column_names:\n            if not column.startswith(\"column_\"):\n                msg = (\n                    \"specified column names do not start with 'column_',\"\n                    \" but autogenerated header names were requested\"\n                )\n                raise ValueError(msg)\n\n    if schema_overrides is not None and not isinstance(\n        schema_overrides, (dict, Sequence)\n    ):\n        msg = \"`schema_overrides` should be of type list or dict\"\n        raise TypeError(msg)\n\n    if raise_if_empty is None:\n        raise_if_empty = schema is None or has_header\n\n    if (\n        use_pyarrow\n        and schema_overrides is None\n        and n_rows is None\n        and not low_memory\n        and null_values is None\n        and with_column_names is None\n        and credential_provider == \"auto\"\n        and include_file_paths is None\n    ):\n        include_columns: Sequence[str] | None = None\n        if column_names:\n            if not has_header:\n                # Convert 'column_0', 'column_1', ... column names to 'f0', 'f1', ...","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/csv/functions.py#L359-L395","documentation":"The `schema_overrides` argument of `read_csv` accepts only a dict mapping column names to dtypes, or a sequence (list) of dtypes. `_read_csv` validates the argument type up front and raises this TypeError for anything else (e.g. a single dtype, a string, a tuple of mixed content, or a set).","triggerScenarios":"`pl.read_csv(..., schema_overrides=str)` or passing an int/set/single pl.DataType object, or a non-iterable object instead of a list/dict of dtypes.","commonSituations":"Confusing `schema_overrides` with `schema` (which expects different shapes); passing one dtype intending it to apply to all columns; passing a dict-like custom mapping that isn't a dict instance; older code using the removed `dtype` parameter name.","solutions":["Wrap a single dtype in a list: `schema_overrides=[pl.Int64]`.","Use a dict keyed by column name for targeted overrides: `schema_overrides={\"id\": pl.Utf8}`.","Ensure the value is a real `dict` or `Sequence` (tuple/list), not a generator or set.","Migrate from the legacy `dtype=` parameter name to `schema_overrides=`."],"exampleFix":"// before\npl.read_csv(\"f.csv\", schema_overrides=pl.Int64)\n# after\npl.read_csv(\"f.csv\", schema_overrides={\"id\": pl.Int64})","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from collections.abc import Sequence\ndef is_valid_schema_overrides(so) -> bool:\n    return so is None or isinstance(so, (dict, Sequence)) and not isinstance(so, (str, bytes))","tryCatchPattern":"try:\n    df = pl.read_csv(path, schema_overrides=so)\nexcept TypeError as e:\n    if \"schema_overrides\" in str(e):\n        so = [so]  # wrap single dtype\n        df = pl.read_csv(path, schema_overrides=so)\n    else:\n        raise","preventionTips":["Always pass schema_overrides as a dict {column: dtype} or list of dtypes.","Remember strings/bytes are Sequences — a bare dtype name string is still invalid.","Migrate legacy `dtype=` kwargs to `schema_overrides=`."],"tags":["python","csv","type-error","schema"],"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"}