Make defaults minimally invasive
Currently in addition to highlighting the error messages, pretty_errors will attempt to make them more concise by removing information in default traceback messages. This is a suggestion, and not necessarily a problem with the package, but it causes confusion when you don't expect this package to be imported.
The issue I had was torchmetrics imported this package, which patched the sys.execpthook, which left me very confused as to where the filepaths in my traceback went: https://github.com/Lightning-AI/torchmetrics/discussions/2544
If this package just highlighted the errors instead of removing the paths to the files they occurred in, then I would have loved the new unexpected behavior.
Because you need to already need have context in order to understand which files the filename-only method refers to perhaps getting that more concise set of errors should be an opt-in configuration? I.e. be minimally invasive by default and let the user choose if they want more complex behavior?
Now that I understand why this highlighting is happening, I'm in a better position to actually use it.
I've installed a sitecustomize config into my venv site-packages, and I'm wondering what the no-op configuration would look like? I basically want the vanilla Python error message experience, except with highlighting.
What would I need to change to get that behavior in this config:
pretty_errors.configure(
#always_display_bottom = True,
#arrow_head_character = '^',
#arrow_tail_character = '-',
#display_arrow = True,
display_link = False,
display_locals = False,
display_timestamp = False,
#display_trace_locals = False,
#exception_above = False,
#exception_below = True,
filename_display = pretty_errors.FILENAME_FULL,
#full_line_newline = False,
#infix = None,
#inner_exception_message = None,
#inner_exception_separator = False,
#line_length = 0,
#line_number_first = False,
#lines_after = 0,
#lines_before = 0,
#postfix = None,
#prefix = None,
#reset_stdout = False,
#separator_character = '-',
#show_suppressed = False,
#stack_depth = 0,
#timestamp_function = time.perf_counter,
#top_first = False,
#trace_lines_after = 0,
#trace_lines_before = 0,
#truncate_code = False,
#truncate_locals = True,
#arrow_head_color = '\x1b[1;32m',
#arrow_tail_color = '\x1b[1;32m',
#code_color = '\x1b[1;30m',
#exception_arg_color = '\x1b[1;33m',
#exception_color = '\x1b[1;31m',
#exception_file_color = '\x1b[1;35m',
#filename_color = '\x1b[1;36m',
#function_color = '\x1b[1;34m',
#header_color = '\x1b[1;30m',
#line_color = '\x1b[1;37m',
#line_number_color = '\x1b[1;32m',
#link_color = '\x1b[1;30m',
#local_len_color = '\x1b[1;30m',
#local_name_color = '\x1b[1;35m',
#local_value_color = '\x1b[m',
#syntax_error_color = '\x1b[1;32m',
#timestamp_color = '\x1b[1;30m',
name = "custom" # name it whatever you want
)
Is that even possible?
I think it'd be easier to use one of the other error prettifier packages than try to configure this one back to the default behavior. It's probably do-able, but a lot of hassle.