From ded0425c8a19ef3832dbb22acc91954f90347b94 Mon Sep 17 00:00:00 2001 From: Thrasher Date: Fri, 23 Oct 2026 20:34:57 +0300 Subject: [PATCH] Fix async examples in README The Future example compared the result to 2 instead of IO(2), and the FutureResult example passed the function instead of calling it. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 886fec5d8..1bf30a6b3 100644 --- a/README.md +++ b/README.md @@ -540,10 +540,11 @@ However, `Future` still requires to be executed inside a proper eventloop: ```python import anyio # or asyncio, or any other lib +from returns.io import IO # We can then pass our `Future` to any library: asyncio, trio, curio. # And use any event loop: regular, uvloop, even a custom one, etc -assert anyio.run(second().awaitable) == 2 +assert anyio.run(second().awaitable) == IO(2) ``` As you can see `Future` allows you @@ -579,8 +580,9 @@ async def raising(): raise ValueError('Not so fast!') -ioresult = anyio.run(raising.awaitable) # all `Future`s return IO containers -assert ioresult == IOFailure(ValueError('Not so fast!')) # True +ioresult = anyio.run(raising().awaitable) # all `Future`s return IO containers +assert isinstance(ioresult, IOFailure) +assert str(ioresult) == '>' ``` Using `FutureResult` will keep your code safe from exceptions.