code: def _detect_term_type():
          
          if os.name == 'nt':
              if os.environ.get('TERM') == 'xterm':
                  # maybe MinTTY
                  return 'mintty'
              else:
                  return 'nt'
          if platform.system().upper().startswith('CYGWIN'):
              return 'cygwin'
          return 'posix'
docs: Detect the type of the terminal.