python / python/typeshed

asyncio.as_completed as async iterator can yield tasks as well as futures

Open
#15,644 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

According to the 3.13 docs for asyncio.as_completed:

When asynchronous iteration is used, the originally-supplied awaitables are yielded if they are tasks or futures.

The relevant stub, however, has the function yield Futures irrespective of whether it was originally supplied with Futures or Tasks.

https://github.com/python/typeshed/blob/c03c2b926422c82ab680d27f3ad2491845000802/stdlib/asyncio/tasks.pyi#L93

Is there a reason for this or can it be improved to reflect the actual behavior?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with stdlib/asyncio/tasks.pyi around line 93 and compare the as_completed stub with the Python 3.13 documentation linked in the issue. Check how the async-iterator result is currently typed for supplied Futures and Tasks, then verify that the final annotation reflects the documented behavior for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.