class documentation

class FancyFormatter: (source)

View In Hierarchy

Apply color and bold font to terminal output.

This currently only works on Linux and Mac.

Method __init__ Undocumented
Method colorize Colorize an output line by highlighting the status and error code.
Method fit​_in​_terminal Improve readability by wrapping error messages and trimming source code.
Method format​_error Format a short summary in case of errors.
Method format​_success Format short summary in case of success.
Method highlight​_quote​_groups Make groups quoted with double quotes bold (including quotes).
Method initialize​_unix​_colors Return True if initialization was successful and we can use colors, False otherwise
Method initialize​_win​_colors Return True if initialization was successful and we can use colors, False otherwise
Method style Apply simple color and style (underlined or bold).
Method underline​_link Underline a link in a note message (if any).
Instance Variable BLUE Undocumented
Instance Variable BOLD Undocumented
Instance Variable colors Undocumented
Instance Variable DIM Undocumented
Instance Variable dummy​_term Undocumented
Instance Variable GREEN Undocumented
Instance Variable NORMAL Undocumented
Instance Variable RED Undocumented
Instance Variable show​_error​_codes Undocumented
Instance Variable UNDER Undocumented
Instance Variable YELLOW Undocumented
def __init__(self, f_out, f_err, show_error_codes): (source)

Undocumented

Parameters
f​_out:IO[str]Undocumented
f​_err:IO[str]Undocumented
show​_error​_codes:boolUndocumented
def colorize(self, error): (source)
Colorize an output line by highlighting the status and error code.
Parameters
error:strUndocumented
Returns
strUndocumented
def fit_in_terminal(self, messages, fixed_terminal_width=None): (source)
Improve readability by wrapping error messages and trimming source code.
Parameters
messages:List[str]Undocumented
fixed​_terminal​_width:Optional[int]Undocumented
Returns
List[str]Undocumented
def format_error(self, n_errors, n_files, n_sources, *, blockers=False, use_color=True): (source)
Format a short summary in case of errors.
Parameters
n​_errors:intUndocumented
n​_files:intUndocumented
n​_sources:intUndocumented
blockers:boolUndocumented
use​_color:boolUndocumented
Returns
strUndocumented
def format_success(self, n_sources, use_color=True): (source)

Format short summary in case of success.

n_sources is total number of files passed directly on command line, i.e. excluding stubs and followed imports.

Parameters
n​_sources:intUndocumented
use​_color:boolUndocumented
Returns
strUndocumented
def highlight_quote_groups(self, msg): (source)

Make groups quoted with double quotes bold (including quotes).

This is used to highlight types, attribute names etc.

Parameters
msg:strUndocumented
Returns
strUndocumented
def initialize_unix_colors(self): (source)
Return True if initialization was successful and we can use colors, False otherwise
Returns
boolUndocumented
def initialize_win_colors(self): (source)
Return True if initialization was successful and we can use colors, False otherwise
Returns
boolUndocumented
def style(self, text, color, bold=False, underline=False, dim=False): (source)
Apply simple color and style (underlined or bold).
Parameters
text:strUndocumented
color:Literal['red', 'green', 'blue', 'yellow', 'none']Undocumented
bold:boolUndocumented
underline:boolUndocumented
dim:boolUndocumented
Returns
strUndocumented
def underline_link(self, note): (source)

Underline a link in a note message (if any).

This assumes there is at most one link in the message.

Parameters
note:strUndocumented
Returns
strUndocumented
BLUE = (source)

Undocumented

BOLD = (source)

Undocumented

colors = (source)

Undocumented

Undocumented

dummy_term = (source)

Undocumented

GREEN = (source)

Undocumented

NORMAL = (source)

Undocumented

Undocumented

show_error_codes = (source)

Undocumented

UNDER = (source)

Undocumented

YELLOW = (source)

Undocumented