Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/danom/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
U = TypeVar("U")
E = TypeVar("E")
P = ParamSpec("P")
S = TypeVar("S", bound="_BaseStream")

MapFn = Callable[P, U]
FilterFn = Callable[P, bool]
Expand Down Expand Up @@ -68,6 +69,11 @@ def fold(
self, initial: T, fn: Callable[[T, U], T], *, workers: int = 1, use_threads: bool = False
) -> T: ...

@abstractmethod
def sequence(
self, *, workers: int = 1, use_threads: bool = False
) -> Result[S, E] | Either[S, E]: ...

@abstractmethod
def collect(self) -> tuple[U, ...]: ...

Expand Down Expand Up @@ -337,8 +343,8 @@ def partition(
return (Stream.from_iterable(pos), Stream.from_iterable(neg))

def sequence(
self, *, workers: int = 1, use_threads: bool = False
) -> Result[T, E] | Either[T, E]:
self: Stream[T], *, workers: int = 1, use_threads: bool = False
) -> Result[Stream[T], E] | Either[Stream[T], E]:
"""Convert a ``Stream`` of ``Result`` or ``Either`` monads to a monad of Stream

.. doctest::
Expand Down
Loading