{"record":{"id":"8229b68e281bfcd3","repo":"pola-rs/polars","slug":"dtypes-must-be-fully-specified-got-tp-r","errorCode":null,"errorMessage":"dtypes must be fully-specified, got: {tp!r}","messagePattern":"dtypes must be fully-specified, got: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/schema.py","lineNumber":56,"sourceCode":"    from polars._dependencies import pyarrow as pa\n\n\ndef _required_init_args(tp: DataTypeClass) -> bool:\n    return bool(tp.__annotations__)\n\n\nBaseSchema = OrderedDict[str, DataType]\nSchemaInitDataType: TypeAlias = DataType | DataTypeClass | PythonDataType\n\n__all__ = [\"Schema\"]\n\n\ndef _check_dtype(tp: DataType | DataTypeClass) -> DataType:\n    if not isinstance(tp, DataType):\n        # note: if nested/decimal, or has signature params, this implies required args\n        if tp.is_nested() or tp.is_decimal() or _required_init_args(tp):\n            msg = f\"dtypes must be fully-specified, got: {tp!r}\"\n            raise TypeError(msg)\n        tp = tp()\n    return tp  # type: ignore[return-value]\n\n\ndef _is_arrow_schema_exportable(obj: Any) -> TypeIs[ArrowSchemaExportable]:\n    return hasattr(obj, \"__arrow_c_schema__\")\n\n\nclass Schema(BaseSchema):\n    \"\"\"\n    Ordered mapping of column names to their data type.\n\n    Parameters\n    ----------\n    schema\n        The schema definition given by column names and their associated\n        Polars data type. Accepts a mapping, or an iterable of tuples, or any\n        object implementing the  `__arrow_c_schema__` PyCapsule interface","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/schema.py#L38-L74","documentation":"pl.Schema validates dtypes: simple dtype classes (pl.Int64, pl.String) are auto-instantiated, but nested/parametric types (List, Struct, Array, Enum, Decimal) must be fully specified because they require constructor args. Passing a bare parametric class raises TypeError.","triggerScenarios":"pl.Schema({'a': pl.List}), pl.Schema({'a': pl.Array}), pl.Schema({'a': pl.Enum}), pl.Schema({'a': pl.Decimal}); building schemas programmatically from classes instead of instances.","commonSituations":"Hand-written schema fixtures/config; copying a dtype CLASS from docs or type annotations (e.g. pl.List instead of pl.List(pl.Int64)); extracting type(x) instead of the instance.","solutions":["Fully instantiate the dtype: pl.List(pl.Int64), pl.Array(pl.Int64, 3), pl.Enum(['a','b']), pl.Decimal(38, 10)","Copy real instances from df.schema rather than re-typing classes","As a last resort construct with check_dtypes=False (skips validation, stores the bare class - only if downstream tolerates it)"],"exampleFix":"# before\npl.Schema({'a': pl.List})\n\n# after\npl.Schema({'a': pl.List(pl.Int64)})","handlingStrategy":"type-guard","validationCode":"from polars.datatypes import is_polars_dtype\n\ndef fully_specified(tp) -> bool:\n    return (\n        isinstance(tp, DataTypeInstance := __import__('polars').DataType)\n        or not (tp.is_nested() or tp.is_decimal())\n    ) if is_polars_dtype(tp, include_unknown=True) else False","typeGuard":"import polars as pl\nfrom polars._utils.parse import _required_init_args\n\ndef is_fully_specified_dtype(tp) -> bool:\n    if isinstance(tp, pl.DataType):\n        return True  # instance: already parameterized\n    return not (tp.is_nested() or tp.is_decimal() or _required_init_args(tp))","tryCatchPattern":null,"preventionTips":["Prefer dtype instances from df.schema over hand-written classes","Nested and decimal dtypes always need their parameters in pl.Schema"],"tags":["polars","schema","dtype","validation"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}