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

Method bind_async

returns/future.py:253–281  ·  view source on GitHub ↗

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

(
        self,
        function: Callable[
            [_ValueType_co],
            Awaitable[Kind1['Future', _NewValueType]],
        ],
    )

Source from the content-addressed store, hash-verified

251 bind_future = bind
252
253 def bind_async(
254 self,
255 function: Callable[
256 [_ValueType_co],
257 Awaitable[Kind1['Future', _NewValueType]],
258 ],
259 ) -> 'Future[_NewValueType]':
260 """
261 Compose a container and ``async`` function returning a container.
262
263 This function should return a container value.
264 See :meth:`~Future.bind_awaitable`
265 to bind ``async`` function that returns a plain value.
266
267 .. code:: python
268
269 >>> import anyio
270 >>> from returns.future import Future
271 >>> from returns.io import IO
272
273 >>> async def coroutine(x: int) -> Future[str]:
274 ... return Future.from_value(str(x + 1))
275
276 >>> assert anyio.run(
277 ... Future.from_value(1).bind_async(coroutine).awaitable,
278 ... ) == IO('2')
279
280 """
281 return Future(_future.async_bind_async(function, self._inner_value))
282
283 #: Alias for `bind_async` method. Part of the `FutureBasedN` interface.
284 bind_async_future = bind_async

Callers

nothing calls this directly

Calls 1

FutureClass · 0.85

Tested by

no test coverage detected