Skip to content

Respect NO_COLOR by disabling ANSI output#5129

Merged
cobaltt7 merged 4 commits into
psf:mainfrom
kkkkwe4324:main
May 19, 2026
Merged

Respect NO_COLOR by disabling ANSI output#5129
cobaltt7 merged 4 commits into
psf:mainfrom
kkkkwe4324:main

Conversation

@kkkkwe4324

Copy link
Copy Markdown
Contributor

Summary

Disable ANSI color output when NO_COLOR is set.
Applies to colored diffs (--diff --color) and report styling.
Keeps behavior unchanged when NO_COLOR is not set.
Details

Add a shared helper to guard styling and diff coloring based on NO_COLOR.
Ensure report styling uses the same guard so summary lines are plain text.
Tests

python -m pytest test_black.py -k "no_color"

<img width="1056" height="144" alt="屏幕截图 2026-05-13 105133" src="https://github.com/user-attachments/assets/7
屏幕截图 2026-05-13 105127
230d8c6-ca59-4ab7-85ce-ca1fde4b2c37" />
屏幕截图 2026-05-13 105119

@cobaltt7

cobaltt7 commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks! Please add a changelog entry and run Black on itself (black . in the repo root).
This closes #3074.

@cobaltt7 cobaltt7 linked an issue May 13, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (2848abf) to main (2b13ea7):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

@cobaltt7 cobaltt7 merged commit 70e0956 into psf:main May 19, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants