1717from prompt_toolkit .styles import Style
1818from prompt_toolkit .keys import Keys
1919from contextlib import contextmanager
20+ from io import StringIO
2021import prompt_toolkit as _pt
2122import threading as _threading
2223import keyboard as _keyboard
2627import time as _time
2728import sys as _sys
2829import os as _os
29- import io
3030
3131try :
3232 from mypy_extensions import mypyc_attr # type: ignore[import]
@@ -1844,14 +1844,15 @@ def _redraw_display(self) -> None:
18441844
18451845
18461846@mypyc_attr (native_class = False )
1847- class _InterceptedOutput ( io . StringIO ) :
1847+ class _InterceptedOutput :
18481848 """Custom StringIO that captures output and stores it in the progress bar buffer."""
18491849
18501850 def __init__ (self , progress_bar : ProgressBar | Spinner ):
1851- super (). __init__ ()
1851+ self . string_io = StringIO ()
18521852 self .progress_bar = progress_bar
18531853
18541854 def write (self , content : str ) -> int :
1855+ self .string_io .write (content )
18551856 try :
18561857 if content and content != "\r " :
18571858 self .progress_bar ._buffer .append (content )
@@ -1861,10 +1862,14 @@ def write(self, content: str) -> int:
18611862 raise
18621863
18631864 def flush (self ) -> None :
1865+ self .string_io .flush ()
18641866 try :
18651867 if self .progress_bar .active and self .progress_bar ._buffer :
18661868 self .progress_bar ._flush_buffer ()
18671869 self .progress_bar ._redraw_display ()
18681870 except Exception :
18691871 self .progress_bar ._emergency_cleanup ()
18701872 raise
1873+
1874+ def __getattr__ (self , name : str ) -> Any :
1875+ return getattr (self .string_io , name )
0 commit comments