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

Method awaitable

returns/future.py:652–672  ·  view source on GitHub ↗

Transforms ``FutureResult[a, b]`` to ``Awaitable[IOResult[a, b]]``. Use this method when you need a real coroutine. Like for ``asyncio.run`` calls. Note, that returned value will be wrapped in :class:`returns.io.IOResult` container. .. code:: pytho

(self)

Source from the content-addressed store, hash-verified

650 return self.awaitable().__await__()
651
652 async def awaitable(self) -> IOResult[_ValueType_co, _ErrorType_co]:
653 """
654 Transforms ``FutureResult[a, b]`` to ``Awaitable[IOResult[a, b]]``.
655
656 Use this method when you need a real coroutine.
657 Like for ``asyncio.run`` calls.
658
659 Note, that returned value will be wrapped
660 in :class:`returns.io.IOResult` container.
661
662 .. code:: python
663
664 >>> import anyio
665 >>> from returns.future import FutureResult
666 >>> from returns.io import IOSuccess
667 >>> assert anyio.run(
668 ... FutureResult.from_value(1).awaitable,
669 ... ) == IOSuccess(1)
670
671 """
672 return IOResult.from_result(await self._inner_value)
673
674 def swap(self) -> 'FutureResult[_ErrorType_co, _ValueType_co]':
675 """

Callers 1

__await__Method · 0.95

Calls 1

from_resultMethod · 0.45

Tested by

no test coverage detected