Skip to content
This repository was archived by the owner on Jan 31, 2026. It is now read-only.
This repository was archived by the owner on Jan 31, 2026. It is now read-only.

result.safe for generator functions #80

@katunilya

Description

@katunilya

Support result safe for generator functions. Imagine we have a function that returns a generator of some typical values:

def func() -> Iterable[int]:
  yield from range(10)

Currently @result.safe_iterate decorator is useless as it won't catch an exception.

It would be better to have @result.safe_iterable decorator that would consider function to return many values and wrap each one into the Result container:

@result.safe_iterate
def func() -> Iterable[int]:  # after decorator applied signature would be () -> Iterable[Result[int, Exception]]
  yield from range(10)

Metadata

Metadata

Assignees

Labels

featNew feature or requestminorCompleting this issue should bump minor version

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions