code: def is_capable_terminal(file=sys.stderr) -> bool:
      
      if not os.isatty(file.fileno()):
          return False
      terminal = os.getenv("TERM", "dumb")
      # Hardcoded list of non-capable terminals.
      return terminal not in ["dumb", "emacs"]
docs: Determine whether we are connected to a capable terminal.