Skip to content

Commit

Permalink
Tweak progress bar docs.
Browse files Browse the repository at this point in the history
There is no good reason as to why the progress bar can't be set back to its indeterminate state (and you could actually do it with code) so this removes the docstring that says that a progress bar can't go back to its indeterminate state.

Related issue: #3268
Related Discord message: https://discord.com/channels/1026214085173461072/1033754296224841768/1149742624002023594
  • Loading branch information
rodrigogiraoserrao committed Sep 12, 2023
1 parent 0f9d189 commit 7c027f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Breaking change: Widget.notify and App.notify now return None https://github.com/Textualize/textual/pull/3275
- App.unnotify is now private (renamed to App._unnotify) https://github.com/Textualize/textual/pull/3275
- `Markdown.load` will now attempt to scroll to a related heading if an anchor is provided https://github.com/Textualize/textual/pull/3244
- `ProgressBar` explicitly supports being set back to its indeterminate state https://github.com/Textualize/textual/pull/3285

## [0.36.0] - 2023-09-05

Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ class ProgressBar(Widget, can_focus=False):
"""The total number of steps associated with this progress bar, when known.
The value `None` will render an indeterminate progress bar.
Once `total` is set to a numerical value, it cannot be set back to `None`.
"""
percentage: reactive[float | None] = reactive[Optional[float]](None)
"""The percentage of progress that has been completed.
Expand Down Expand Up @@ -398,6 +397,7 @@ def advance(self, advance: float = 1) -> None:
```py
progress_bar.advance(10) # Advance 10 steps.
```
Args:
advance: Number of steps to advance progress by.
"""
Expand Down
12 changes: 9 additions & 3 deletions tests/test_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ def test_update_total():
pb.update(total=1000)
assert pb.total == 1000

pb.update(total=None)
assert pb.total == 1000

pb.update(total=100)
assert pb.total == 100

Expand Down Expand Up @@ -119,6 +116,15 @@ def test_update():
assert pb.progress == 50


def test_go_back_to_indeterminate():
pb = ProgressBar()

pb.total = 100
assert pb.percentage == 0
pb.total = None
assert pb.percentage is None


@pytest.mark.parametrize(
["show_bar", "show_percentage", "show_eta"],
[
Expand Down

0 comments on commit 7c027f5

Please sign in to comment.