Skip to content

Allow binary streams in tqdm write stubs - #16953

Open
Lushiyao5 wants to merge 2 commits into
python:mainfrom
Lushiyao5:fix-tqdm-binary-write-types
Open

Lushiyao5 wants to merge 2 commits into
python:mainfrom
Lushiyao5:fix-tqdm-binary-write-types

Conversation

@Lushiyao5

Copy link
Copy Markdown
Contributor

tqdm.write() writes the message and terminator directly to the supplied stream. Both can be bytes when that stream accepts bytes. Add an overload requiring a binary stream and an explicit binary terminator, since the default terminator is text. Accept the same binary streams in external_write_mode().

I verified both text and binary writes with StringIO and BytesIO. Mypy accepts both valid calls and still rejects a missing binary terminator, a text stream for binary data, or binary data without an explicit stream. The updated stub also passed mypy.

This patch was prepared with assistance from OpenAI Codex.

@github-actions

github-actions Bot commented Dec 2, 2026

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