Skip to content

Commit 9c963ea

Browse files
authored
Merge branch 'develop' into copilot/fix-deprecation-warning-date-parsing
2 parents 0c153cf + 24cfd2e commit 9c963ea

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

progressbar/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@ def create_argument_parser() -> argparse.ArgumentParser:
6262
Create the argument parser for the `progressbar` command.
6363
"""
6464

65-
parser = argparse.ArgumentParser(
66-
description="""
65+
description = """
6766
Monitor the progress of data through a pipe.
6867
6968
Note that this is a Python implementation of the original `pv` command
7069
that is functional but not yet feature complete.
7170
"""
72-
)
71+
parser = argparse.ArgumentParser(description=description)
7372

7473
# Display switches
7574
parser.add_argument(

progressbar/bar.py

Lines changed: 3 additions & 4 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
@@ -1095,8 +1095,7 @@ def currval(self):
10951095
progressbar package.
10961096
"""
10971097
warnings.warn(
1098-
'The usage of `currval` is deprecated, please use '
1099-
'`value` instead',
1098+
'The usage of `currval` is deprecated, please use `value` instead',
11001099
DeprecationWarning,
11011100
stacklevel=1,
11021101
)

progressbar/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,5 @@ def is_terminal(
185185
'vt(10[02]|220|320)',
186186
)
187187
ANSI_TERM_RE: re.Pattern[str] = re.compile(
188-
f"^({'|'.join(ANSI_TERMS)})", re.IGNORECASE
188+
f'^({"|".join(ANSI_TERMS)})', re.IGNORECASE
189189
)

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)