pola-rs/polars · error · TypeError

cannot parse input {input_type} into Polars data type{input_

Error message

cannot parse input {input_type} into Polars data type{input_detail}

What it means

Error "cannot parse input {input_type} into Polars data type{input_detail}" thrown in pola-rs/polars.

Source

Thrown at py-polars/src/polars/datatypes/_parse.py:197

    input
        A union type, e.g. `str | None` (new syntax) or `Union[str, None]` (old syntax).
    """
    # Strip "optional" designation - Polars data types are always nullable
    inner_types = [tp for tp in get_args(input) if tp is not NoneType]

    if len(inner_types) != 1:
        _raise_on_invalid_dtype(input)

    input = inner_types[0]
    return parse_into_dtype(input)


def _raise_on_invalid_dtype(input: Any) -> NoReturn:
    """Raise an informative error if the input could not be parsed."""
    input_type = input if type(input) is type else f"of type {type(input).__name__!r}"
    input_detail = "" if type(input) is type else f" (given: {input!r})"
    msg = f"cannot parse input {input_type} into Polars data type{input_detail}"
    raise TypeError(msg) from None

View on GitHub (pinned to df599052da)

When it happens

Trigger: Thrown at py-polars/src/polars/datatypes/_parse.py:197 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16). Data as JSON: /api/errors/697073b5b59ed115. Report an issue: GitHub.