Skip to content

fix: keep stepped range progress totals aligned#9582

Open
GHX5T-SOL wants to merge 2 commits into
marimo-team:mainfrom
GHX5T-SOL:fix/9575-progress-bar-range-step
Open

fix: keep stepped range progress totals aligned#9582
GHX5T-SOL wants to merge 2 commits into
marimo-team:mainfrom
GHX5T-SOL:fix/9575-progress-bar-range-step

Conversation

@GHX5T-SOL
Copy link
Copy Markdown

This pull request was authored by a coding agent.

Summary

  • Fix mo.status.progress_bar(range(...)) when total is inferred, so stepped ranges track the number of yielded items instead of advancing past the inferred total.
  • Preserve existing explicit-total behavior for stepped ranges, where range.step is used with the caller-provided total.
  • Add regressions for both inferred and explicit totals on 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.py
  • uv run ruff format --check marimo/_plugins/stateless/status/_progress.py tests/_plugins/stateless/status/test_progress.py
  • uv run --only-group typecheck mypy marimo/_plugins/stateless/status/_progress.py
  • git diff --check
  • git diff | gitleaks stdin --no-banner --redact --timeout 30

Limitations

  • I ran focused Python/status validation only; I did not run the full test suite or a browser UI smoke.
  • I did not take any account/legal action for the CLA beyond reading the contribution guidance.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 18, 2026 8:01pm

Request Review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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
Loading

Re-trigger cubic

@GHX5T-SOL GHX5T-SOL marked this pull request as ready for review May 18, 2026 19:47
@mscolnick
Copy link
Copy Markdown
Contributor

@GHX5T-SOL, please sign the CLA

@GHX5T-SOL
Copy link
Copy Markdown
Author

recheck

@GHX5T-SOL
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

)

if isinstance(collection, range):
if total_was_provided and isinstance(collection, range):
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.

Thanks, but this could be an elif

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed this to an elif in 45db08c. Thanks.

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.

mo.status.progress_bar should use the step property of 'range'

3 participants