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

Method from_failure

returns/future.py:1451–1472  ·  view source on GitHub ↗

Creates ``FutureResult`` from failed value. .. code:: python >>> import anyio >>> from returns.io import IOFailure >>> from returns.future import FutureResult >>> async def main(): ... assert await FutureResult.from_failure(

(
        cls,
        inner_value: _NewErrorType,
    )

Source from the content-addressed store, hash-verified

1449
1450 @classmethod
1451 def from_failure(
1452 cls,
1453 inner_value: _NewErrorType,
1454 ) -> 'FutureResult[Any, _NewErrorType]':
1455 """
1456 Creates ``FutureResult`` from failed value.
1457
1458 .. code:: python
1459
1460 >>> import anyio
1461 >>> from returns.io import IOFailure
1462 >>> from returns.future import FutureResult
1463
1464 >>> async def main():
1465 ... assert await FutureResult.from_failure(
1466 ... 1,
1467 ... ) == IOFailure(1)
1468
1469 >>> anyio.run(main)
1470
1471 """
1472 return FutureResult(async_identity(Failure(inner_value)))
1473
1474
1475def FutureSuccess( # noqa: N802

Callers 2

from_failed_ioMethod · 0.45
FutureFailureFunction · 0.45

Calls 3

FailureClass · 0.90
FutureResultClass · 0.85
async_identityFunction · 0.85

Tested by

no test coverage detected