File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change @@ -185,5 +185,5 @@ def is_terminal(
185185 'vt(10[02]|220|320)' ,
186186)
187187ANSI_TERM_RE : re .Pattern [str ] = re .compile (
188- f" ^({ '|' .join (ANSI_TERMS )} )" , re .IGNORECASE
188+ f' ^({ "|" .join (ANSI_TERMS )} )' , re .IGNORECASE
189189)
Original file line number Diff line number Diff line change @@ -207,7 +207,6 @@ strict = [
207207reportIncompatibleMethodOverride = false
208208reportUnnecessaryIsInstance = false
209209reportUnnecessaryCast = false
210- reportUnnecessaryTypeAssertion = false
211210reportUnnecessaryComparison = false
212211reportUnnecessaryContains = false
213212
Original file line number Diff line number Diff 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' )
104117def test_fd_as_standard_streams (stream ) -> None :
You can’t perform that action at this time.
0 commit comments