Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: keep stepped range progress totals aligned (#9582)

Ghxst ☠️b5bdd95a7bfd
diff --git a/marimo/_plugins/stateless/status/_progress.py b/marimo/_plugins/stateless/status/_progress.py
index 82e6ed60ea..6311acb5a1 100644
--- a/marimo/_plugins/stateless/status/_progress.py
+++ b/marimo/_plugins/stateless/status/_progress.py
@@ -404,7 +404,7 @@ class progress_bar(Generic[S]):
"A `total` must be provided."
)
- if isinstance(collection, range):
+ elif 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 2c4978e5d0..81240621df 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