Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions progressbar/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ def create_argument_parser() -> argparse.ArgumentParser:
Create the argument parser for the `progressbar` command.
"""

parser = argparse.ArgumentParser(
description="""
description = """
Monitor the progress of data through a pipe.

Note that this is a Python implementation of the original `pv` command
that is functional but not yet feature complete.
"""
)
parser = argparse.ArgumentParser(description=description)

# Display switches
parser.add_argument(
Expand Down
7 changes: 3 additions & 4 deletions progressbar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _format_widgets(self):

count = len(expanding)
while expanding:
portion = max(int(math.ceil(width * 1.0 / count)), 0)
portion = max(math.ceil(width / count), 0)
index = expanding.pop()
widget = result[index]
count -= 1
Expand Down Expand Up @@ -410,7 +410,7 @@ def _handle_resize(
self, signum: int | None = None, frame: None | FrameType = None
):
"Tries to catch resize signals sent from the terminal."
w, h = utils.get_terminal_size()
w, _h = utils.get_terminal_size()
self.term_width = w

def finish(self): # pragma: no cover
Expand Down Expand Up @@ -1095,8 +1095,7 @@ def currval(self):
progressbar package.
"""
warnings.warn(
'The usage of `currval` is deprecated, please use '
'`value` instead',
'The usage of `currval` is deprecated, please use `value` instead',
DeprecationWarning,
stacklevel=1,
)
Expand Down
2 changes: 1 addition & 1 deletion progressbar/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ def is_terminal(
'vt(10[02]|220|320)',
)
ANSI_TERM_RE: re.Pattern[str] = re.compile(
f"^({'|'.join(ANSI_TERMS)})", re.IGNORECASE
f'^({"|".join(ANSI_TERMS)})', re.IGNORECASE
)
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ strict = [
reportIncompatibleMethodOverride = false
reportUnnecessaryIsInstance = false
reportUnnecessaryCast = false
reportUnnecessaryTypeAssertion = false
reportUnnecessaryComparison = false
reportUnnecessaryContains = false

Expand Down
13 changes: 13 additions & 0 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ def test_no_newlines() -> None:
bar.update(i)


def test_update_keeps_colors_when_enabled() -> None:
stream = io.StringIO()
with progressbar.ProgressBar(
fd=stream,
widgets=['\033[92mgreen\033[0m'],
max_value=1,
enable_colors=True,
) as bar:
bar.update(1)

assert '\033[92mgreen\033[0m' in stream.getvalue()


@pytest.mark.parametrize('stream', [sys.__stdout__, sys.__stderr__])
@pytest.mark.skipif(os.name == 'nt', reason='Windows does not support this')
def test_fd_as_standard_streams(stream) -> None:
Expand Down
Loading