Repository navigation
Fix #1658: apply disp_trim to all format_meter return paths - #1717
Merged
Merged
Conversation
format_meter has 6 return statements but only 2 applied disp_trim
when ncols is set. This meant custom bar_format without {bar} and
the no-total stats-only path would not respect ncols, producing
output wider than the terminal.
Now all return paths (except ncols==0 which is intentionally compact)
apply disp_trim consistently.
Fixes tqdm#1658
casperdcl
force-pushed
the
master
branch
3 times, most recently
from
June 9, 2026 13:22
a09a105 to
4b33952
Compare
Member
|
Thanks for this! Apologies for the delay. Merged with #1767. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
format_meterhas 6 return statements but only 2 applieddisp_trimwhenncolsis set. This meant custombar_formatwithout{bar}and the no-total stats-only path would produce output wider than the terminal.Fix
Applied
disp_trim(result, ncols) if ncols else resultto the 3 return paths that were missing it:bar_formatwithout{bar}, with total (line 633)bar_formatwithout{bar}, without total (line 652)bar_format, no total - stats only (line 660)The
ncols==0early return (line 618) is left as-is since it intentionally produces a compact format.Test
Added
test_disp_trim_all_format_meter_pathsthat verifies all three paths respectncols=20trimming. Without the fix, the first assertion fails (disp_lenis 38, exceeding ncols of 20).Full test suite passes (71 tests) on macOS ARM (Apple Silicon).
Fixes #1658