MCPcopy Index your code
hub / github.com/dry-python/returns / bind_async

Method bind_async

returns/future.py:823–859  ·  view source on GitHub ↗

Composes a container and ``async`` function returning container. This function should return a container value. See :meth:`~FutureResult.bind_awaitable` to bind ``async`` function that returns a plain value. .. code:: python >>> import anyio

(
        self,
        function: Callable[
            [_ValueType_co],
            Awaitable[Kind2['FutureResult', _NewValueType, _ErrorType_co]],
        ],
    )

Source from the content-addressed store, hash-verified

821 bind_future_result = bind
822
823 def bind_async(
824 self,
825 function: Callable[
826 [_ValueType_co],
827 Awaitable[Kind2['FutureResult', _NewValueType, _ErrorType_co]],
828 ],
829 ) -> 'FutureResult[_NewValueType, _ErrorType_co]':
830 """
831 Composes a container and ``async`` function returning container.
832
833 This function should return a container value.
834 See :meth:`~FutureResult.bind_awaitable`
835 to bind ``async`` function that returns a plain value.
836
837 .. code:: python
838
839 >>> import anyio
840 >>> from returns.future import FutureResult
841 >>> from returns.io import IOSuccess, IOFailure
842
843 >>> async def coroutine(x: int) -> FutureResult[str, int]:
844 ... return FutureResult.from_value(str(x + 1))
845
846 >>> assert anyio.run(
847 ... FutureResult.from_value(1).bind_async(coroutine).awaitable,
848 ... ) == IOSuccess('2')
849 >>> assert anyio.run(
850 ... FutureResult.from_failure(1).bind_async(coroutine).awaitable,
851 ... ) == IOFailure(1)
852
853 """
854 return FutureResult(
855 _future_result.async_bind_async(
856 function,
857 self._inner_value,
858 )
859 )
860
861 #: Alias for `bind_async` method.
862 #: Part of the `FutureResultBasedN` interface.

Callers

nothing calls this directly

Calls 1

FutureResultClass · 0.85

Tested by

no test coverage detected