Skip to content

Commit

Permalink
rename variable to update_min_steps
Browse files Browse the repository at this point in the history
  • Loading branch information
srafi1 committed Nov 1, 2020
1 parent 210f1e0 commit d3c5e05
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/click/_termui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
label=None,
file=None,
color=None,
update_interval=1,
update_min_steps=1,
width=30,
):
self.fill_char = fill_char
Expand All @@ -78,7 +78,7 @@ def __init__(
file = _default_text_stdout()
self.file = file
self.color = color
self.update_interval = update_interval
self.update_min_steps = update_min_steps
self.completed_intervals = 0
self.width = width
self.autowidth = width == 0
Expand Down Expand Up @@ -297,7 +297,7 @@ def update(self, n_steps, current_item=None):
Added the ``current_item`` optional parameter.
"""
self.completed_intervals += n_steps
if self.completed_intervals >= self.update_interval:
if self.completed_intervals >= self.update_min_steps:
self.make_step(self.completed_intervals)
if current_item is not None:
self.current_item = current_item
Expand Down
9 changes: 4 additions & 5 deletions src/click/termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def progressbar(
width=36,
file=None,
color=None,
update_interval=1,
update_min_steps=1,
):
"""This function creates an iterable context manager that can be used
to iterate over something while showing a progress bar. It will
Expand Down Expand Up @@ -361,7 +361,7 @@ def progressbar(
progressbar object.
.. versionadded:: 8.0
Added the `update_interval` parameter and changed `update()`
Added the `update_min_steps` parameter and changed `update()`
method to utilize it.
:param iterable: an iterable to iterate over. If not provided the length
Expand Down Expand Up @@ -402,8 +402,7 @@ def progressbar(
default is autodetection. This is only needed if ANSI
codes are included anywhere in the progress bar output
which is not the case by default.
:param update_interval: Renders the bar every time this many updates have
:param update_min_steps: Renders the bar every time this many updates have
completed. This allows user to skip unnecessary
renders for frequently updated iterators.
"""
Expand All @@ -425,7 +424,7 @@ def progressbar(
label=label,
width=width,
color=color,
update_interval=update_interval,
update_min_steps=update_min_steps,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def cli():
assert "Custom 4" in lines[2]


def test_progress_bar_update_interval(runner):
bar = _create_progress(update_interval=5)
def test_progress_bar_update_min_steps(runner):
bar = _create_progress(update_min_steps=5)
bar.update(3)
assert bar.completed_intervals == 3
assert bar.pos == 0
Expand Down

0 comments on commit d3c5e05

Please sign in to comment.