{"record":{"id":"568d47e06a3938da","repo":"pola-rs/polars","slug":"unsupported-data-type-dtype-568d47","errorCode":null,"errorMessage":"unsupported data type: {dtype}","messagePattern":"unsupported data type: (.+?)","errorType":"validation","errorClass":"InvalidArgument","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/testing/parametric/strategies/dtype.py","lineNumber":272,"sourceCode":"        return Datetime(time_unit, time_zone)\n    elif dtype == Duration:\n        time_unit = draw(_time_units())\n        return Duration(time_unit)\n    elif dtype == Categorical:\n        return Categorical()\n    elif dtype == Enum:\n        n_categories = draw(\n            st.integers(min_value=1, max_value=_DEFAULT_ENUM_CATEGORIES_LIMIT)\n        )\n        categories = [f\"c{i}\" for i in range(n_categories)]\n        return Enum(categories)\n    elif dtype == Decimal:\n        precision = draw(st.integers(min_value=1, max_value=38) | st.none())\n        scale = draw(st.integers(min_value=0, max_value=precision or 38))\n        return Decimal(precision, scale)\n    else:\n        msg = f\"unsupported data type: {dtype}\"\n        raise InvalidArgument(msg)\n\n\n@st.composite\ndef _nested_dtypes(\n    draw: DrawFn,\n    inner: SearchStrategy[DataType],\n    allowed_dtypes: Sequence[PolarsDataType] | None = None,\n    excluded_dtypes: Sequence[PolarsDataType] | None = None,\n    *,\n    allow_time_zones: bool = True,\n) -> DataType:\n    \"\"\"Create a strategy for generating nested Polars :class:`DataType` objects.\"\"\"\n    if allowed_dtypes is None:\n        allowed_dtypes = _NESTED_DTYPES\n    if excluded_dtypes is None:\n        excluded_dtypes = []\n\n    dtype = draw(st.sampled_from(allowed_dtypes))","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/testing/parametric/strategies/dtype.py#L254-L290","documentation":"_instantiate_flat_dtype in strategies/dtype.py draws a concrete flat dtype from a DataTypeClass/selection; dtypes it cannot instantiate fall through to the final else and raise InvalidArgument. It is the flat-dtype instantiation path used by _flat_dtypes and the inner strategy machinery.","triggerScenarios":"Hypothesis drawing a dtype class that _instantiate_flat_dtype does not recognize (e.g. a nested-only or plugin dtype appearing in the flat-dtype pool); passing an unsupported dtype class into series()/instantiate helpers that route through the flat path.","commonSituations":"Custom or third-party dtypes used with parametric testing; polars version drift introducing a dtype not yet covered in dtype.py; accidentally requesting nested dtypes through a flat-dtype entry point.","solutions":["Restrict generated dtypes to supported flat ones via the `extra_dtypes`/`blocked_dtypes`-style selection or by passing explicit dtypes.","Update strategies/dtype.py to handle the new dtype in _instantiate_flat_dtype.","Ensure nested dtypes go through _instantiate_nested_dtype / _nested_dtypes, not the flat path."],"exampleFix":"// before\nseries(dtype=MyCustomDtype)\n// after\nseries(dtype=pl.Int64)","handlingStrategy":"validation","validationCode":"FLAT = {pl.Int8, pl.Int16, pl.Int32, pl.Int64, pl.UInt8, pl.UInt16, pl.UInt32, pl.UInt64, pl.Float32, pl.Float64, pl.String, pl.Boolean, pl.Date, pl.Time}\nif not any(dtype == d for d in FLAT):\n    raise ValueError(f\"{dtype} is not an instantiable flat dtype here\")","typeGuard":"def is_flat_supported(dtype) -> bool:\n    return not dtype.is_nested() and dtype not in (pl.Unknown,)","tryCatchPattern":"from polars.exceptions import InvalidArgument\ntry:\n    dt = instantiate(dtype)\nexcept InvalidArgument as e:\n    dt = pl.Int64  # fallback default for the test pool","preventionTips":["Restrict drawn dtypes to the supported flat pool via selection filters.","Route nested dtypes through the nested instantiation path, not the flat one.","Re-run hypothesis tests after polars upgrades to catch new unsupported dtypes."],"tags":["polars","hypothesis","dtype","testing"],"backgroundTag":"unsupported-dtype","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"}