Skip to content

Fix async examples in README - #2553

Merged
sobolevn merged 1 commit into
dry-python:masterfrom
thrashxr:fix-readme-async-examples
Oct 23, 2026
Merged

sobolevn merged 1 commit into
dry-python:masterfrom
thrashxr:fix-readme-async-examples

Conversation

@thrashxr

Copy link
Copy Markdown
Contributor

I have made things!

Two async examples in the README fail when copied and run.

The Future example returns an IO container, not a plain value:

>>> assert anyio.run(second().awaitable) == 2
AssertionError
>>> anyio.run(second().awaitable)
<IO: 2>

The FutureResult example passes the function instead of calling it:

>>> anyio.run(raising.awaitable)
AttributeError: 'function' object has no attribute 'awaitable'

With the call fixed, the comparison is still False, because two separate ValueError instances are not equal:

>>> anyio.run(raising().awaitable) == IOFailure(ValueError('Not so fast!'))
False

This compares against IO(2) in the first example, and in the second one calls raising() and checks the result type and its string form, the same way docs/pages/future.rst does.

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Docs-only change (README examples), so no new tests or CHANGELOG entry. I ran the fixed examples locally and the existing test suite passes.

Related issues

Refs #1618

The Future example compared the result to 2 instead of IO(2), and the
FutureResult example passed the function instead of calling it.

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@codspeed

codspeed Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 note

ℹ️ 2 benchmarks have no flamegraph

The flamegraph wasn't generated: the symbols of the profiling trace could not be resolved, because no information about the language frames was collected.

See affected benchmarks

✅ 22 untouched benchmarks


Comparing thrashxr:fix-readme-async-examples (ded0425) with master (808c168)

Open in CodSpeed

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (82ef3ef) to head (ded0425).
⚠️ Report is 645 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #2553    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           80        82     +2     
  Lines         2485      2692   +207     
  Branches       437        44   -393     
==========================================
+ Hits          2485      2692   +207     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sobolevn
sobolevn merged commit 62d21c4 into dry-python:master Oct 23, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants