GeezerVison is showing github.com — Use color to highlight error locations · Issue #112730 · python/cpython
Use color to highlight error locations #112730DescriptionThis has several advantages:
- Will help a lot with readability as parsing the error lines is easier if color highlights the error ranges.
- In the future we can optionally (via config) drop the ranges and only use color, recovering back the extra lines that the carets are taking.
- All the cool kids are doing it: This feature has already been successfully implemented in various tools. It has proven to be an effective aid for developers in quickly identifying the source and location of errors.
Control features:
- The feature will use 16 ANSI color scapes so the actual color is configured via the terminal emulator.
- Users can set the following env vars to control it (in the following order):
Linked PRs
Reacted by André Roberge, Rajarishi Devarajan, tuxayo and Yashas G V Reacted by Hugo van Kemenade, Kirill Podoprigora, Erlend E. Aasland, baggiponte, itzAkari, Mohamed El Mouctar Haidara, Alex Waygood, Rajarishi Devarajan and tuxayo Activityhugovk commented on Dec 5, 2023 pablogsal commented on Dec 5, 2023
Perhaps something for a followup, can we customise the colouring a bit?
Yup, see #112732 (comment).
I want to explore customization options AFTER we land the basic version first. EDIT Or are you referring to customizing the coloring as "adding more colors"?
On the other hand, are you suggesting to also colorize the name of the exception, the file, the number and the Traceback text?
I have been told that yellow and cian are really bad for light mode, so we should do something else there. pablogsal commented on Dec 5, 2023 hugovk commented on Dec 5, 2023 I wasn't thinking about allowing the user to customise them (although that's something to consider) but about having different colours for the different elements (exception name, file, etc).
Yes, we should check the contrast is good for both light and dark modes.
The GitHub colours (ignoring the plain black/white text) look the same for each mode and display well for both:


edit: and the blues are different, but you get the idea :) pablogsal commented on Dec 5, 2023 I am quite colorblind myself 😅 Do you mind telling me what colors are supposed to be every piece? As in "filename is ..., line number is ...., function name is ..., source code is ..., error location is ...) Reacted by Hugo van Kemenade pablogsal commented on Apr 8, 2024 Maybe we could just add a support decorator that just does the appropriate monkey patching in the colorise function to avoid being affected by the force colours variable. To avoid regressions, setting FORCE_COLORS in GH actions sounds like a good idea. pablogsal commented on Apr 8, 2024
I personally think it's very useful for Python to use the same env vars that are being increasingly widely adopted elsewhere. So I suppose I lean towards changing -E so that it also ignores the FORCE_COLOR variable.
I think if we don't do this it's going to be a full pain for us and a lot of users that have the variable set in CI and are running subprocesses in tests added a commit that references this issue on Apr 24, 2024gh-112730: Make the test suite resilient to color-activation environm… encukou commented on Apr 25, 2024 #117672 broke several stable buildbots, see e.g. here. As Jakub noted they seem to be --enable-shared builds that rely on LD_LIBRARY_PATH to find libpython.
Do you have time to look into this? pablogsal commented on Apr 25, 2024 I will look into this today. We can revert in the meanwhile if you wish added 2 commits that reference this issue on Apr 25, 2024gh-112730: Respect tests that require environment variables with no-c… pablogsal commented on Apr 26, 2024 I think this will be fixed by #118288 hugovk commented on Jun 15, 2024
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|