From 44f6f12618d30eaae0e28567c4eceff035690366 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 18 Apr 2026 01:57:59 +0000 Subject: [PATCH 1/3] Plan tox build fixes Agent-Logs-Url: https://github.com/wolph/python-progressbar/sessions/7a92701d-42dc-4a5a-85a7-458e27ca00b2 Co-authored-by: wolph <270571+wolph@users.noreply.github.com> --- progressbar/__main__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/progressbar/__main__.py b/progressbar/__main__.py index 0bfd7fb..5fb0b7f 100644 --- a/progressbar/__main__.py +++ b/progressbar/__main__.py @@ -62,14 +62,12 @@ def create_argument_parser() -> argparse.ArgumentParser: Create the argument parser for the `progressbar` command. """ - parser = argparse.ArgumentParser( - description=""" + parser = argparse.ArgumentParser(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. - """ - ) + """) # Display switches parser.add_argument( From 47e4c3e7749e12800eb033ac234a404e32924ec5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 18 Apr 2026 01:58:22 +0000 Subject: [PATCH 2/3] Apply tox failure fixes Agent-Logs-Url: https://github.com/wolph/python-progressbar/sessions/7a92701d-42dc-4a5a-85a7-458e27ca00b2 Co-authored-by: wolph <270571+wolph@users.noreply.github.com> --- progressbar/bar.py | 4 ++-- pyproject.toml | 1 - tests/test_stream.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/progressbar/bar.py b/progressbar/bar.py index 34ba02c..12f013b 100644 --- a/progressbar/bar.py +++ b/progressbar/bar.py @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 1a484a9..6374f98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -207,7 +207,6 @@ strict = [ reportIncompatibleMethodOverride = false reportUnnecessaryIsInstance = false reportUnnecessaryCast = false -reportUnnecessaryTypeAssertion = false reportUnnecessaryComparison = false reportUnnecessaryContains = false diff --git a/tests/test_stream.py b/tests/test_stream.py index d14845d..e32bbd5 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -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: From 0104aea296de50dd31dcc08b2d555f88ee1d4e80 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 18 Apr 2026 02:00:21 +0000 Subject: [PATCH 3/3] Finalize formatter-compatible tox fixes Agent-Logs-Url: https://github.com/wolph/python-progressbar/sessions/7a92701d-42dc-4a5a-85a7-458e27ca00b2 Co-authored-by: wolph <270571+wolph@users.noreply.github.com> --- progressbar/__main__.py | 5 +++-- progressbar/bar.py | 3 +-- progressbar/env.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/progressbar/__main__.py b/progressbar/__main__.py index 5fb0b7f..b4b4e9a 100644 --- a/progressbar/__main__.py +++ b/progressbar/__main__.py @@ -62,12 +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( diff --git a/progressbar/bar.py b/progressbar/bar.py index 12f013b..c349370 100644 --- a/progressbar/bar.py +++ b/progressbar/bar.py @@ -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, ) diff --git a/progressbar/env.py b/progressbar/env.py index 3871c2e..d2faae0 100644 --- a/progressbar/env.py +++ b/progressbar/env.py @@ -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 )