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

[REQUEST] Enable colours when FORCE_COLOR env var is set #2425

Closed
hugovk opened this issue Jul 27, 2022 · 1 comment · Fixed by #2449
Closed

[REQUEST] Enable colours when FORCE_COLOR env var is set #2425

hugovk opened this issue Jul 27, 2022 · 1 comment · Fixed by #2449
Assignees
Labels
accepted Task was accepted enhancement New feature or request

Comments

@hugovk
Copy link
Contributor

hugovk commented Jul 27, 2022

Have you checked the issues for a similar suggestions?

Yes, initially rejected at #343 but further discussed more favourably at pypa/pip#10909 (comment).

How would you improve Rich?

If the FORCE_COLOR environment variable is set -- to any value -- then enable the use of colour.

(I'm not specifically requesting it here, but could be worth considering: If the NO_COLOR environment variable is set -- to any value -- then disable the use of colour. NO_COLOR should override FORCE_COLOR. Re: https://no-color.org/)

What problem does it solve for you?

What problem do you have that this feature would solve? I may be able to suggest an existing way of solving it.

pip 22 now uses Rich for installation progress bars and some error handling, which gives us pretty colours! And more of pip's interface is being switched over to use Rich for improved usability.

image

Colour can help diagnose problems, and a common place for pip and the need to diagnose problems is on a CI, where you get a big wall of text.

However, because GitHub Actions isn't a tty, output of tools which autodetect the terminal output is usually monochrome. That's why many tools and CI setups use the FORCE_COLOR environment variable, and/or command-line options to turn it back on.

For example, pip's CI (#10830):

https://github.com/pypa/pip/blob/4a508c268ee4be5bc279f1522954b78fa9e25050/.github/workflows/ci.yml#L14-L17

However, Rich doesn't support FORCE_COLOR, meaning we get monochrome output:

image

Compare with nox:

image

https://github.com/pypa/pip/runs/5177210581?check_suite_focus=true

And pytest:

image

https://github.com/pytest-dev/pytest/runs/5185781927?check_suite_focus=true

For reference:

This would benefit not just users of pip, but users of other software which uses Rich as a colour/style library, and mean they do not need to implement it themselves, and Rich would be on par with other colour libraries.

@willmcgugan willmcgugan added enhancement New feature or request accepted Task was accepted and removed Needs triage labels Aug 5, 2022
@darrenburns darrenburns linked a pull request Aug 16, 2022 that will close this issue
9 tasks
@darrenburns darrenburns self-assigned this Aug 16, 2022
@github-actions
Copy link

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Task was accepted enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants