(s: str, color: Optional[str])
return '\u001b[' + codes[color] + s + '\u001b[0m'
Colorize string `s` by wrapping in ANSI escape sequence for given `color`.

    This function does not consider whether escape sequences are functional or not; it is up to the caller to determine
    if its appropriate. Check global `ansi_color_enabled` value in this module.
Colorize string `s` by wrapping in ANSI escape sequence for given `color`.
Colorize string s by wrapping in ANSI escape sequence for given color .
def ansi_color(s: str, color: Optional[str]) -> str:
    """
    Colorize string `s` by wrapping in ANSI escape sequence for given `color`.

    This function does not consider whether escape sequences are functional or not; it is up to the caller to determine
    if its appropriate. Check global `ansi_color_enabled` value in this module.
    """
    if color is None:
        return s

    codes = {
        'black':          '30m',
        'bright_black':   '90m',
        'gray':           '90m',  # alias 'bright black'
        'blue':           '34m',
        'bright_blue':    '94m',
        'cyan':           '36m',
        'bright_cyan':    '96m',
        'green':          '32m',
        'bright_green':   '92m',
        'magenta':        '35m',
        'bright_magenta': '95m',
        'red':            '31m',
        'bright_red':     '91m',
        'white':          '37m',
        'bright_white':   '97m',
        'yellow':         '33m',
        'bright_yellow':  '93m',
    }
    return '\u001b[' + codes[color] + s + '\u001b[0m'
def ansi_color ( s : str , color : Optional [ str ] ) -> str : if color is None : return s codes = { 'black' : '30m' , 'bright_black' : '90m' , 'gray' : '90m' , # alias 'bright black' 'blue' : '34m' , 'bright_blue' : '94m' , 'cyan' : '36m' , 'bright_cyan' : '96m' , 'green' : '32m' , 'bright_green' : '92m' , 'magenta' : '35m' , 'bright_magenta' : '95m' , 'red' : '31m' , 'bright_red' : '91m' , 'white' : '37m' , 'bright_white' : '97m' , 'yellow' : '33m' , 'bright_yellow' : '93m' , } return '\u001b[' + codes [ color ] + s + '\u001b[0m'