Conversation
When update_min_steps is not a divisor of the iterable length, finish() would leave _completed_intervals unflushed, causing pos to not reflect the actual number of items processed. This resulted in show_pos displaying e.g. '14/20' instead of '20/20' at completion. Fix by flushing any remaining _completed_intervals in finish() before marking the bar as finished. Fixes pallets#3571
Member
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.
Fix: progressbar not showing full completion with
update_min_stepsFixes #3571.
Problem
When using
click.progressbarwithshow_pos=Trueand anupdate_min_stepsthat isn't a divisor of the iterable length, the final display shows an incomplete position (e.g.,14/20instead of20/20).Root Cause
finish()marks the bar as complete but does not flush the remaining_completed_intervalsaccumulated since the last render. Theposattribute stays at the last rendered value rather than the actual total.Fix
Flush any remaining
_completed_intervalsviamake_step()at the start offinish(), before settingfinished = True. This is a no-op when_completed_intervalsis already 0 (i.e., whenupdate_min_stepsevenly divides the length).Testing