eotransform.sinks.result.SinkUnwrapped
- class SinkUnwrapped(wrapped_sink: Sink[SinkT], ignore_exceptions=None)[source]
Bases:
Sink[Result[SinkT,ErrT]]Unwrap a result object before passing it onto the wrapped sink. Also allows for automatically ignoring exceptions. >>> class RecordingSink(Sink[int]): … def __init__(self): … self.record = [] … def __call__(self, x: int) -> None: … self.record.append(x) >>> sink = RecordingSink() >>> SinkUnwrapped(sink)(Result.ok(42)) >>> sink.record [42] >>> SinkUnwrapped(sink, ignore_exceptions={RuntimeError})(Result.error(RuntimeError(“An error to be ignored”))) >>> sink.record [42]
@param wrapped_sink: sink to which the unwrapped object is passed @param ignore_exceptions: set of exception types to be ignored
Methods