Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions py-polars/src/polars/datatypes/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def _parse_generic_into_dtype(input: Any) -> PolarsDataType:
_raise_on_invalid_dtype(input)

inner_type = inner_types[0]
if isinstance(inner_type, UnionType) or get_origin(inner_type) is Union:
return _parse_union_type_into_dtype(input)
inner_dtype = parse_py_type_into_dtype(inner_type)
return List(inner_dtype)

Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/datatypes/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_dtypes_hashable() -> None:

@pytest.mark.parametrize(
"python_type",
[int, int | None, Optional[int], Union[int, None]], # noqa: UP007,UP045
[int, int | None, Optional[int], Union[int, None], list[Optional[int]]], # noqa: UP007,UP045
)
def test_inference_from_python_type(python_type: Any) -> None:
polars_type = pl.DataType.from_python(python_type)
Expand Down
Loading