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

Method bind_awaitable

returns/future.py:286–316  ·  view source on GitHub ↗

Allows to compose a container and a regular ``async`` function. This function should return plain, non-container value. See :meth:`~Future.bind_async` to bind ``async`` function that returns a container. .. code:: python >>> import anyio

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

Source from the content-addressed store, hash-verified

284 bind_async_future = bind_async
285
286 def bind_awaitable(
287 self,
288 function: Callable[[_ValueType_co], 'Awaitable[_NewValueType]'],
289 ) -> 'Future[_NewValueType]':
290 """
291 Allows to compose a container and a regular ``async`` function.
292
293 This function should return plain, non-container value.
294 See :meth:`~Future.bind_async`
295 to bind ``async`` function that returns a container.
296
297 .. code:: python
298
299 >>> import anyio
300 >>> from returns.future import Future
301 >>> from returns.io import IO
302
303 >>> async def coroutine(x: int) -> int:
304 ... return x + 1
305
306 >>> assert anyio.run(
307 ... Future.from_value(1).bind_awaitable(coroutine).awaitable,
308 ... ) == IO(2)
309
310 """
311 return Future(
312 _future.async_bind_awaitable(
313 function,
314 self._inner_value,
315 )
316 )
317
318 def bind_io(
319 self,

Callers

nothing calls this directly

Calls 1

FutureClass · 0.85

Tested by

no test coverage detected