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

Don't colour diff headers white, only bold #2691

Merged
merged 2 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Improve error message for invalid regular expression (#2678)
- Fix mapping cases that contain as-expressions, like `case {"key": 1 | 2 as password}`
(#2686)
- No longer color diff headers white as it's unreadable in light themed terminals
(#2691)

## 21.12b0

Expand Down
2 changes: 1 addition & 1 deletion src/black/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def color_diff(contents: str) -> str:
lines = contents.split("\n")
for i, line in enumerate(lines):
if line.startswith("+++") or line.startswith("---"):
line = "\033[1;37m" + line + "\033[0m" # bold white, reset
line = "\033[1m" + line + "\033[0m" # bold, reset
elif line.startswith("@@"):
line = "\033[36m" + line + "\033[0m" # cyan, reset
elif line.startswith("+"):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_piping_diff_with_color(self) -> None:
)
actual = result.output
# Again, the contents are checked in a different test, so only look for colors.
self.assertIn("\033[1;37m", actual)
self.assertIn("\033[1m", actual)
self.assertIn("\033[36m", actual)
self.assertIn("\033[32m", actual)
self.assertIn("\033[31m", actual)
Expand Down Expand Up @@ -323,7 +323,7 @@ def test_expression_diff_with_color(self) -> None:
actual = result.output
# We check the contents of the diff in `test_expression_diff`. All
# we need to check here is that color codes exist in the result.
self.assertIn("\033[1;37m", actual)
self.assertIn("\033[1m", actual)
self.assertIn("\033[36m", actual)
self.assertIn("\033[32m", actual)
self.assertIn("\033[31m", actual)
Expand Down