fix: keep stepped range progress totals aligned#9582
Open
GHX5T-SOL wants to merge 2 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant User as User Code
participant PB as progress_bar()
participant PR as ProgressBar <br/>_progress.py
participant PBar as Progress <br/>bar component
User->>PB: progress_bar(range(0, 10, 2))
PB->>PR: __init__(collection=range, total=None)
PR->>PR: total_was_provided = (total is not None)
PR->>PR: total is None → infer total
alt No explicit total
PR->>PR: total = len(range) = 5
PR->>PR: collection is range →<br/>total_was_provided is False →<br/>skip step override
PR->>PR: step remains default 1
else Explicit total provided
User->>PB: progress_bar(range(0, 10, 2), total=10)
PB->>PR: __init__(collection=range, total=10)
PR->>PR: total_was_provided = True
PR->>PR: total = 10 (caller-provided)
PR->>PR: collection is range AND<br/>total_was_provided is True →<br/>step = collection.step = 2
end
PR-->>PB: ProgressBar instance
PB-->>User: ProgressBar instance
Note over User,PBar: Iteration
loop Over range(0, 10, 2)
User->>PR: next()
PR->>PBar: update(step=1)
PBar-->>PR: current += 1
PR-->>User: [0, 2, 4, 6, 8]
end
Note over User,PBar: Final state differs by branch
alt No explicit total
User->>PR: check progress.current, progress.total
PR-->>User: (5, 5) — tracks yielded items
else Explicit total
User->>PR: check progress.current, progress.total
PR-->>User: (10, 10) — step applied to caller's total
end
Contributor
|
@GHX5T-SOL, please sign the CLA |
Author
|
recheck |
Author
|
I have read the CLA Document and I hereby sign the CLA |
dmadisetti
reviewed
May 18, 2026
| ) | ||
|
|
||
| if isinstance(collection, range): | ||
| if total_was_provided and isinstance(collection, range): |
Collaborator
There was a problem hiding this comment.
Thanks, but this could be an elif
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.
This pull request was authored by a coding agent.
Summary
mo.status.progress_bar(range(...))whentotalis inferred, so stepped ranges track the number of yielded items instead of advancing past the inferred total.range.stepis used with the caller-provided total.range(0, 10, 2).Closes #9575.
Validation
uv run --group test pytest tests/_plugins/stateless/status/test_progress.py -q(15 passed)uv run ruff check marimo/_plugins/stateless/status/_progress.py tests/_plugins/stateless/status/test_progress.pyuv run ruff format --check marimo/_plugins/stateless/status/_progress.py tests/_plugins/stateless/status/test_progress.pyuv run --only-group typecheck mypy marimo/_plugins/stateless/status/_progress.pygit diff --checkgit diff | gitleaks stdin --no-banner --redact --timeout 30Limitations