def _context_result_function( argument: int, ) -> RequiresContextResult[int, int, str]: return RequiresContextResult(lambda other: Success(argument + other))
def _context_result_function( argument: int, ) -> RequiresContextResult[int, int, str]: if argument > 0: return RequiresContextResult(lambda deps: Success(argument + deps)) return RequiresContextResult.from_failure('nope')
def factory(inner_value: int) -> RequiresContextResult[float, str, int]: return RequiresContextResult(lambda deps: Success(inner_value / deps))
from returns.context import ContextResult, RequiresContextResult 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', [ RequiresContextResult(lambda _: Success(1)), RequiresContextResult(lambda _: Failure(1)), RequiresContextResult.from_success(1), RequiresContextResult.from_failure(1), RequiresContextResult.from_result(Success(1)), RequiresContextResult.from_result(Failure(1)), ContextResult.ask(), ]) @pytest.mark.parametrize('protocol', [ Bindable, Mappable, Rescueable, Unwrapable, Altable, Fixable, Unitable,