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

Refactor to support the NO_COLOR argument and deprecate PIPENV_COLORBLIND #5185

Merged
merged 5 commits into from
Jul 24, 2022

Conversation

matteius
Copy link
Member

Follow-up to make NO_COLOR work and deprecated PIPENV_COLORBLIND.

The issue

There was some issues with the prior monkey patch suggested approach: #5184

So I opened this PR instead.

@matteius matteius mentioned this pull request Jul 23, 2022
@matteius matteius requested a review from oz123 July 23, 2022 22:33
PIPENV_COLORBLIND = bool(os.environ.get("PIPENV_COLORBLIND"))
"""If set, disable terminal colors.
NO_COLOR = False
if env_to_bool(os.getenv("NO_COLOR")) or env_to_bool(os.getenv("PIPENV_COLORBLIND")):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to refer to no-color.org, we should also adopt their convention.
NO_COLOR should be a non empty string:

Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color.

By using env_to_bool we deviate from this behavior. Personally, I think it's better to use explicit boolean string, but it's hard fixing the whole world. We should stick to non-empty string IMO.

from pipenv.utils.shell import style_no_color
from pipenv.vendor import click

click.original_style = click.style
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to keep around click.style with click.original_style.

@oz123 oz123 merged commit 2b895ff into main Jul 24, 2022
@oz123 oz123 deleted the support_NO_COLOR branch July 24, 2022 07:04
oz123 pushed a commit that referenced this pull request Jul 25, 2022
…ables (#5185)

* Refactor to support the NO_COLOR argument and deprecate PIPENV_COLORBIND variable.

* Add news fragment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants