docs: def choose_palette(stream=sys.stdout, basic_palette=None):
      ''' Make a best effort to automatically determine whether to enable
          ANSI sequences, and if so, which color palettes are available.
  
          This is the main function of the module—meant to be used unless
          something more specific is needed.
  
          Takes the following factors into account:
  
          - Whether output stream is a TTY.
          - ``TERM``, ``ANSICON`` environment variables
          - ``CLICOLOR``, ``NO_COLOR`` environment variables
  
          Arguments:
              stream:             Which output file to check: stdout, stderr
              basic_palette:      Force the platform-dependent 16 color palette,
                                  for testing.  List of 16 rgb-int tuples.
          Returns:
              None, str: 'basic', 'extended', or 'truecolor'
      '''
      result = None
      pal = basic_palette
      log.debug('console version: %s', __version__)
      log.debug('X11_RGB_PATHS: %r', X11_RGB_PATHS)
  
      if color_is_forced():
          result, pal = detect_palette_support(basic_palette=pal) or 'basic'
  
      elif is_a_tty(stream=stream) and color_is_allowed():
          result, pal = detect_palette_support(basic_palette=pal)
  
      proximity.build_color_tables(pal)
      log.debug('Basic palette: %r', pal)
      log.debug('%r', result)
      return result