Skip to content

Commit 47e4c3e

Browse files
Copilotwolph
andauthored
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>
1 parent 44f6f12 commit 47e4c3e

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

progressbar/bar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def _format_widgets(self):
368368

369369
count = len(expanding)
370370
while expanding:
371-
portion = max(int(math.ceil(width * 1.0 / count)), 0)
371+
portion = max(math.ceil(width / count), 0)
372372
index = expanding.pop()
373373
widget = result[index]
374374
count -= 1
@@ -410,7 +410,7 @@ def _handle_resize(
410410
self, signum: int | None = None, frame: None | FrameType = None
411411
):
412412
"Tries to catch resize signals sent from the terminal."
413-
w, h = utils.get_terminal_size()
413+
w, _h = utils.get_terminal_size()
414414
self.term_width = w
415415

416416
def finish(self): # pragma: no cover

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ strict = [
207207
reportIncompatibleMethodOverride = false
208208
reportUnnecessaryIsInstance = false
209209
reportUnnecessaryCast = false
210-
reportUnnecessaryTypeAssertion = false
211210
reportUnnecessaryComparison = false
212211
reportUnnecessaryContains = false
213212

tests/test_stream.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ def test_no_newlines() -> None:
9999
bar.update(i)
100100

101101

102+
def test_update_keeps_colors_when_enabled() -> None:
103+
stream = io.StringIO()
104+
with progressbar.ProgressBar(
105+
fd=stream,
106+
widgets=['\033[92mgreen\033[0m'],
107+
max_value=1,
108+
enable_colors=True,
109+
) as bar:
110+
bar.update(1)
111+
112+
assert '\033[92mgreen\033[0m' in stream.getvalue()
113+
114+
102115
@pytest.mark.parametrize('stream', [sys.__stdout__, sys.__stderr__])
103116
@pytest.mark.skipif(os.name == 'nt', reason='Windows does not support this')
104117
def test_fd_as_standard_streams(stream) -> None:

0 commit comments

Comments
 (0)