Returns whether we think the terminal supports basic, extended, or
        truecolor.  None if not able to tell.

        Returns:
            None or str: 'basic', 'extended', 'truecolor'

def detect_palette_support(basic_palette=None):
    ''' Returns whether we think the terminal supports basic, extended, or
        truecolor.  None if not able to tell.

        Returns:
            None or str: 'basic', 'extended', 'truecolor'
    '''
    result = col_init = win_enabled = None
    TERM = env.TERM or ''
    if os_name == 'nt':
        from .windows import (is_ansi_capable, enable_vt_processing,
                              is_colorama_initialized)
        if is_ansi_capable():
            win_enabled = all(enable_vt_processing())
        col_init = is_colorama_initialized()

    # linux, older Windows + colorama
    if TERM.startswith('xterm') or (TERM == 'linux') or col_init:
            result = 'basic'

    # xterm, fbterm, older Windows + ansicon
    if ('256color' in TERM) or (TERM == 'fbterm') or env.ANSICON:
        result = 'extended'

    # https://bugzilla.redhat.com/show_bug.cgi?id=1173688 - obsolete?
    if env.COLORTERM in ('truecolor', '24bit') or win_enabled:
        result = 'truecolor'

    # find the platform-dependent 16-color basic palette
    pal_name = 'Unknown'
    if result and not basic_palette:
        result, pal_name, basic_palette = _find_basic_palette(result)

    try:
        import webcolors
    except ImportError:
        webcolors = None

    log.debug(
        f'{result!r} ({os_name}, TERM={env.TERM or ""}, '
        f'COLORTERM={env.COLORTERM or ""}, ANSICON={env.ANSICON}, '
        f'webcolors={bool(webcolors)}, basic_palette={pal_name})'
    )
    return (result, basic_palette)