Rendering code refactor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import itertools
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from typing import Generic, Protocol, Self, TypeVar
|
||||
@@ -55,3 +56,13 @@ def batched(iterable: Iterable[T], n: int) -> Iterator[tuple[T, ...]]:
|
||||
iterator = iter(iterable)
|
||||
while batch := tuple(itertools.islice(iterator, n)):
|
||||
yield batch
|
||||
|
||||
|
||||
ResultT = TypeVar("ResultT")
|
||||
ErrorT = TypeVar("ErrorT")
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Result(Generic[ResultT, ErrorT]):
|
||||
result: ResultT | None = None
|
||||
error: ErrorT | None = None
|
||||
|
||||
Reference in New Issue
Block a user