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

Method from_value

returns/future.py:385–404  ·  view source on GitHub ↗

Allows to create a ``Future`` from a plain value. The resulting ``Future`` will just return the given value wrapped in :class:`returns.io.IO` container when awaited. .. code:: python >>> import anyio >>> from returns.future import Future

(cls, inner_value: _NewValueType)

Source from the content-addressed store, hash-verified

383
384 @classmethod
385 def from_value(cls, inner_value: _NewValueType) -> 'Future[_NewValueType]':
386 """
387 Allows to create a ``Future`` from a plain value.
388
389 The resulting ``Future`` will just return the given value
390 wrapped in :class:`returns.io.IO` container when awaited.
391
392 .. code:: python
393
394 >>> import anyio
395 >>> from returns.future import Future
396 >>> from returns.io import IO
397
398 >>> async def main() -> bool:
399 ... return (await Future.from_value(1)) == IO(1)
400
401 >>> assert anyio.run(main) is True
402
403 """
404 return Future(async_identity(inner_value))
405
406 @classmethod
407 def from_future(

Callers 2

from_ioMethod · 0.45
FutureSuccessFunction · 0.45

Calls 2

FutureClass · 0.85
async_identityFunction · 0.85

Tested by

no test coverage detected