from collections.abc import Iterable from typing import Any def paginate(items: Iterable[Any], total: int | None = None) -> dict[str, Any]: items_list = list(items) return {"items": items_list, "total": total if total is not None else len(items_list)}