Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Closed
Description
This 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):
PY_COLORS=1
activates the feature (used by pytest:https://github.com/pytest-dev/pytest/blob/022f1b4de546c8b3529e071965555888ecf01cb4/src/_pytest/_io/terminalwriter.py#L28)PY_COLORS=0
deactivates the featureNO_COLOR=1
deactivates the featureFORCE_COLOR=1
activates the feature- Feature is deactivated if terminal is not a tty or if
TERM
is set todumb
.
Linked PRs
- gh-112730: Use color to highlight error locations #112732
- gh-112730: Update docs for colour env vars #112837
- gh-112730: Make the test suite resilient to color-activation environment variables #117672
- gh-112730: use keyword only argument for colorize #118086
- gh-112730: Respect tests that require environment variables with no-colorize fixes #118288