-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Force color #2449
Force color #2449
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2449 +/- ##
==========================================
- Coverage 98.71% 98.59% -0.12%
==========================================
Files 73 72 -1
Lines 7771 7769 -2
==========================================
- Hits 7671 7660 -11
- Misses 100 109 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@willmcgugan would appreciate a review here when you get a chance. |
Thank you for this! Do you have a rough idea of when the next release is? Would be great to get this released, integrated and tested into pip in time for their next release some time on October. |
Potentially as soon as this weekend. |
And it’s out! <3 |
(discoverability comment) PSA: looks like using |
I believe the problem is that this is handled unusually: if both NO_COLOR and FORCE_COLOR are set, instead of avoiding ANSI escapes, it instead makes everything black and white, but still uses ANSI escapes for things like bold text. (Personally, I prefer controlling color by the value of FORCE_COLOR; in plumbum I use the value for the color mode). |
I asked the author of the NO_COLOR spec, and he confirmed that |
For reference: https://github.com/jcs/no_color/issues/240 |
I’m not sure that’s the correct reference. That one says monochrome is still color. :) A big part of the problem is you can’t set NO_COLOR to an empty string or some sort of false value (that’s part of the spec). Unsetting an environment value is sometimes hard (there’s no “none” in TOML, for example, which means tools like cibuildwheel and scikit-build-core can’t undo a set variable via static config since there’s no way to indicate it). But that’s part of the spec, not much that can be done. |
Honestly, reading https://github.com/jcs/no_color/issues/240 I interpreted it differently.. Also, I don't think that “bold” is a good example, since some terminals don't implement it properly and abuse it for making the color brighter. I hit this with Kitty, which implements the standard to the letter and when some apps misuse it, they sometimes ends up printing “invisible” color (as in black on black). |
Exactly, in my case, it's YAML, which does have |
@willmcgugan so it looks like the combination of env vars like One would expect that This brings up a question — which ANSI-codes constitute color? You mentioned bold/italic being non-color, so why does https://force-color.org suggests that
|
Type of changes
Checklist
Description
Adds support for
FORCE_COLOR
environment variable.Presence of this variable in the environment results in
Console.force_terminal = True
.If
FORCE_COLOR
andNO_COLOR
are both set,NO_COLOR
takes priority.NO_COLOR = 1
onlyNO_COLOR = 1
andFORCE_COLOR = 1
FORCE_COLOR = 1
only