code: def __init__(self, file: Optional[TextIO] = None) -> None:
      if file is None:
          file = sys.stdout
      if (
          hasattr(file, "isatty")
          and file.isatty()
          and sys.platform == "win32"
      ):
          try:
              import colorama
          except ImportError:
              pass
          else:
              file = colorama.AnsiToWin32(file).stream
              assert file is not None
      self._file = file
      self.hasmarkup = should_do_markup(file)
      self._current_line = ""
      self._terminal_width: Optional[int] = None
      self.code_highlight = True
  
imports: import os
  import shutil
  import sys
  from typing import Optional
  from typing import Sequence
  from typing import TextIO
  from .wcwidth import wcswidth
  from _pytest.compat import final
label_desc: Use image node_id 1 to create a new TerminalWriter object  with example: obj = TerminalWriter(file)