Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make defaults minimally invasive #61

Open
Erotemic opened this issue May 16, 2024 · 2 comments
Open

Make defaults minimally invasive #61

Erotemic opened this issue May 16, 2024 · 2 comments

Comments

@Erotemic
Copy link

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: Lightning-AI/torchmetrics#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?

@Erotemic
Copy link
Author

Erotemic commented May 22, 2024

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?

@onelivesleft
Copy link
Owner

onelivesleft commented May 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants