Skip to content

[tqdm] Correct the display return type - #16936

Merged
srittau merged 2 commits into
python:mainfrom
Lushiyao5:fix/tqdm-display-result-20261128
Dec 1, 2026
Merged

srittau merged 2 commits into
python:mainfrom
Lushiyao5:fix/tqdm-display-result-20261128

Conversation

@Lushiyao5

Copy link
Copy Markdown
Contributor

The standard tqdm display() method returns True when it writes a progress bar and False when the row is out of range. The stub currently declares None, so mypy rejects code that checks the result. Use bool | None to reflect the standard return value while preserving compatibility with notebook and other overrides that return None.

Verified both outcomes with tqdm 4.70.1 and checked the example plus the standard and notebook stubs with mypy.

Prepared with assistance from OpenAI Codex.

Assisted-by: OpenAI Codex
@github-actions

This comment has been minimized.

Comment thread stubs/tqdm/tqdm/std.pyi
@property
def format_dict(self) -> MutableMapping[str, Any]: ...
def display(self, msg: str | None = None, pos: int | None = None) -> None: ...
def display(self, msg: str | None = None, pos: int | None = None) -> bool | None: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a short comment why None is included in the return types.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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

@srittau
srittau merged commit e1e9d0f into python:main Dec 1, 2026
74 checks passed
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.

2 participants