File size: 427 Bytes
0161e74 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from collections.abc import Iterable
from typing import Any
def _to_list(x: list[Any] | tuple[Any] | Any) -> list[Any] | tuple[Any]:
"""Converts x to a list if it is not already a list or tuple."""
if isinstance(x, (list | tuple)):
return x
return [x]
def _flatten_list(x: Iterable[Iterable[Any]]) -> list[Any]:
"""Flattens a list of lists."""
return [item for sublist in x for item in sublist]
|