From bf52be6b42a53427d210984bfe5fe6a28ee84744 Mon Sep 17 00:00:00 2001 From: GHX5T-SOL <200635707+GHX5T-SOL@users.noreply.github.com> Date: Mon, 18 May 2026 19:43:24 +0200 Subject: [PATCH 1/3] fix: keep stepped range progress totals aligned --- marimo/_plugins/stateless/status/_progress.py | 3 ++- tests/_plugins/stateless/status/test_progress.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/marimo/_plugins/stateless/status/_progress.py b/marimo/_plugins/stateless/status/_progress.py index 82e6ed60ea8..235e9f48bbe 100644 --- a/marimo/_plugins/stateless/status/_progress.py +++ b/marimo/_plugins/stateless/status/_progress.py @@ -392,6 +392,7 @@ def __init__( self.step: int = 1 self.collection = collection self._is_async = isinstance(collection, AsyncIterable) + total_was_provided = total is not None if collection is not None: if total is None: @@ -404,7 +405,7 @@ def __init__( "A `total` must be provided." ) - if isinstance(collection, range): + if total_was_provided and isinstance(collection, range): self.step = cast(range, collection).step elif total is None: diff --git a/tests/_plugins/stateless/status/test_progress.py b/tests/_plugins/stateless/status/test_progress.py index 2c4978e5d04..81240621dff 100644 --- a/tests/_plugins/stateless/status/test_progress.py +++ b/tests/_plugins/stateless/status/test_progress.py @@ -167,6 +167,22 @@ def test_progress_without_context(): pass +def test_progress_with_stepped_range_without_total() -> None: + assert runtime_context_installed() is False + + progress = progress_bar(range(0, 10, 2)) + assert list(progress) == [0, 2, 4, 6, 8] + assert (progress.progress.current, progress.progress.total) == (5, 5) + + +def test_progress_with_stepped_range_and_total() -> None: + assert runtime_context_installed() is False + + progress = progress_bar(range(0, 10, 2), total=10) + assert list(progress) == [0, 2, 4, 6, 8] + assert (progress.progress.current, progress.progress.total) == (10, 10) + + async def sleep(seconds): import asyncio From 4ae12f1ddbebd1958f516057e237dcb02e322d21 Mon Sep 17 00:00:00 2001 From: Ghost Date: Mon, 18 May 2026 21:56:45 +0200 Subject: [PATCH 2/3] fix: address progress review cleanup --- marimo/_plugins/stateless/status/_progress.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marimo/_plugins/stateless/status/_progress.py b/marimo/_plugins/stateless/status/_progress.py index 235e9f48bbe..7cc0fbf2a21 100644 --- a/marimo/_plugins/stateless/status/_progress.py +++ b/marimo/_plugins/stateless/status/_progress.py @@ -405,7 +405,7 @@ def __init__( "A `total` must be provided." ) - if total_was_provided and isinstance(collection, range): + elif total_was_provided and isinstance(collection, range): self.step = cast(range, collection).step elif total is None: From e7d01930f62ff42d4a54c882060dff61bd277719 Mon Sep 17 00:00:00 2001 From: Dylan Madisetti Date: Thu, 21 May 2026 13:10:40 -0700 Subject: [PATCH 3/3] Refactor total check for collection length determination --- marimo/_plugins/stateless/status/_progress.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/marimo/_plugins/stateless/status/_progress.py b/marimo/_plugins/stateless/status/_progress.py index 7cc0fbf2a21..6311acb5a1b 100644 --- a/marimo/_plugins/stateless/status/_progress.py +++ b/marimo/_plugins/stateless/status/_progress.py @@ -392,7 +392,6 @@ def __init__( self.step: int = 1 self.collection = collection self._is_async = isinstance(collection, AsyncIterable) - total_was_provided = total is not None if collection is not None: if total is None: @@ -405,7 +404,7 @@ def __init__( "A `total` must be provided." ) - elif total_was_provided and isinstance(collection, range): + elif isinstance(collection, range): self.step = cast(range, collection).step elif total is None: