File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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
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