def _reader_ioresult_pipeline(self, inner_value): def factory(deps): return _managed( lambda inner: self._use(inner)(deps), lambda inner, pure: self._release(inner, pure)(deps), )(IOResult.from_value(inner_value)) return RequiresContextIOResult(factory)
def _context_io_result_function( argument: int, ) -> RequiresContextIOResult[int, int, str]: return RequiresContextIOResult(lambda other: IOSuccess(argument + other))
from returns.io import IOFailure, IOSuccess from returns.primitives.exceptions import ImmutableStateError from returns.primitives.interfaces import ( Altable, Bindable, Fixable, Mappable, Rescueable, Unitable, Unwrapable, ) from returns.result import Failure, Success @pytest.mark.parametrize('container', [ RequiresContextIOResult(lambda _: IOSuccess(1)), RequiresContextIOResult(lambda _: IOFailure(1)), RequiresContextIOResult.from_success(1), RequiresContextIOResult.from_failure(1), RequiresContextIOResult.from_result(Success(1)), RequiresContextIOResult.from_result(Failure(1)), RequiresContextIOResult.from_ioresult(IOSuccess(1)), RequiresContextIOResult.from_ioresult(IOFailure(1)), ContextIOResult.ask(), ]) @pytest.mark.parametrize('protocol', [ Bindable, Mappable, Rescueable, Unwrapable, Altable,
def _context_ioresult_function( argument: int, ) -> RequiresContextIOResult[int, int, str]: if argument > 0: return RequiresContextIOResult(lambda deps: IOSuccess(argument + deps)) return RequiresContextIOResult.from_failure('nope')