Skip to content

[tqdm] Type as_completed items as coroutines - #16919

Open
Lushiyao5 wants to merge 1 commit into
python:mainfrom
Lushiyao5:fix/tqdm-as-completed-coroutine-20261129
Open

Lushiyao5 wants to merge 1 commit into
python:mainfrom
Lushiyao5:fix/tqdm-as-completed-coroutine-20261129

Conversation

@Lushiyao5

Copy link
Copy Markdown

Synchronous iteration over asyncio.as_completed yields coroutines. tqdm.as_completed uses that iteration interface, but its stub says it yields Future objects. This rejects passing an item to asyncio.create_task, even though that works at runtime. Annotate the iterator items as Coroutine[Any, Any, T].

Verified with tqdm 4.70.1 on Python 3.12: scheduling a yielded item returns the expected integer. mypy rejects create_task on the old stub and accepts it after the change, with the awaited result inferred as int.

Prepared with assistance from OpenAI Codex.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant