1515from python_utils .terminal import get_terminal_size
1616from python_utils .time import epoch , format_time , timedelta_to_seconds
1717
18+ from progressbar import base
19+
1820if types .TYPE_CHECKING :
1921 from .bar import ProgressBar , ProgressBarMixinBase
2022
3941
4042
4143def is_ansi_terminal (
42- fd : types .IO , is_terminal : bool | None = None
44+ fd : base .IO , is_terminal : bool | None = None
4345) -> bool : # pragma: no cover
4446 if is_terminal is None :
4547 # Jupyter Notebooks define this variable and support progress bars
@@ -74,7 +76,7 @@ def is_ansi_terminal(
7476 return bool (is_terminal )
7577
7678
77- def is_terminal (fd : types .IO , is_terminal : bool | None = None ) -> bool :
79+ def is_terminal (fd : base .IO , is_terminal : bool | None = None ) -> bool :
7880 if is_terminal is None :
7981 # Full ansi support encompasses what we expect from a terminal
8082 is_terminal = is_ansi_terminal (fd ) or None
@@ -188,14 +190,14 @@ def env_flag(name: str, default: bool | None = None) -> bool | None:
188190
189191class WrappingIO :
190192 buffer : io .StringIO
191- target : types .IO
193+ target : base .IO
192194 capturing : bool
193195 listeners : set
194196 needs_clear : bool = False
195197
196198 def __init__ (
197199 self ,
198- target : types .IO ,
200+ target : base .IO ,
199201 capturing : bool = False ,
200202 listeners : types .Set [ProgressBar ] = None ,
201203 ) -> None :
@@ -300,8 +302,8 @@ def __exit__(
300302class StreamWrapper :
301303 '''Wrap stdout and stderr globally'''
302304
303- stdout : types .TextIO | WrappingIO
304- stderr : types .TextIO | WrappingIO
305+ stdout : base .TextIO | WrappingIO
306+ stderr : base .TextIO | WrappingIO
305307 original_excepthook : types .Callable [
306308 [
307309 types .Optional [types .Type [BaseException ]],
@@ -366,7 +368,7 @@ def wrap(self, stdout: bool = False, stderr: bool = False) -> None:
366368 if stderr :
367369 self .wrap_stderr ()
368370
369- def wrap_stdout (self ) -> types .IO :
371+ def wrap_stdout (self ) -> base .IO :
370372 self .wrap_excepthook ()
371373
372374 if not self .wrapped_stdout :
@@ -377,7 +379,7 @@ def wrap_stdout(self) -> types.IO:
377379
378380 return sys .stdout
379381
380- def wrap_stderr (self ) -> types .IO :
382+ def wrap_stderr (self ) -> base .IO :
381383 self .wrap_excepthook ()
382384
383385 if not self .wrapped_stderr :
0 commit comments