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
main: fix replacing color codes in tracebacks #335
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
841befa
main: fix replacing color codes in tracebacks
FFY00 8293796
main: add missing reset tag to successfull build message
FFY00 8adb1bb
main: refactor colorization
FFY00 dfa7b6f
tests: add test for colorization
FFY00 672d9dc
main: add FORCE_COLOR
FFY00 d309ec0
main: refactor color detection
FFY00 92884c4
main: add line between backend output and missing dependencies error
FFY00 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that we have an environment variable to disable color, however can we have also one that force enables it? (e.g. tox 4 cannot forward the tty state into a subprocess yet, so is handy in such cases to force color mode). Perhaps FORCE_COLOR? And if neither set then check the tty state 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. What happens with both
FORCE_COLOR
andNO_COLOR
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my implementation NO_COLOR wins, but 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See e.g. how this would be used https://github.com/tox-dev/tox/blob/rewrite/tox.ini#L79 (this shows how mypy handles it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't empty values translate as false for these flags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://no-color.org/ says the mere presence enables the behavior, the value is irrelevant. I think we should have the same behavior in
FORCE_COLOR
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of having a FORCE_COLOR too, as often on GHA (which supports color) things can be missing color. I think no-color.org went overboard - it's a pretty well established practice for an empty environment variable to be the same as unsetting it. It's not always easy to unset an environment variable, and the disconnect there is irritating. But I'd follow what the spec dictates. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the concern and share a similar opinion. IMO, coloring should be disabled if
NO_COLOR
is present and is notno
/false
. But given that it is already a pretty well established standard, I think the best option is to follow what is defined.