Skip to content

[tqdm] Infer the result type of tmap - #16918

Open
Lushiyao5 wants to merge 1 commit into
python:mainfrom
Lushiyao5:fix/tqdm-tmap-result-20261129
Open

Lushiyao5 wants to merge 1 commit into
python:mainfrom
Lushiyao5:fix/tqdm-tmap-result-20261129

Conversation

@Lushiyao5

Copy link
Copy Markdown

The current stub types the values yielded by tmap as incomplete, even when the mapping function has a known return type. Use the callable’s return type for the generator’s item type. For example, tmap(len, ["foo"]) now preserves int as the yielded type.

Verified with mypy: the probe expected Generator[int, None, None] and failed on the base stub (inferred Any items). It passes with the change. The same probe returns the expected values on tqdm 4.70.1.

Prepared with assistance from OpenAI Codex.

Assisted-by: 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