-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add option for printing a colored diff #1266
Conversation
Whoops, wasn't working off the latest master. Fixed and rebased. |
FWIW I like this feature. How about dropping the command line flag and always outputting colored diff if we're writing to a terminal ( As for Windows support, I'd be fine with adding |
I think it would be prudent to keep some CLI flag because I'm sure there are cases where a user wants to write to a terminal but not colorize it. Perhaps we just invert it:
From what I can tell, whenever |
|
||
# wrap_stream returns a `colorama.AnsiToWin32.AnsiToWin32` object | ||
# which does not have a `detach()` method. So we fake one. | ||
f.detach = lambda *args, **kwargs: None # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, but I don't fully understand what detach
does or why it's needed, so this is the best I could come up with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. I'll add a changelog entry and merge this soon. Thanks for contributing!
Seems this PR is closed and merged into master. Yet, when I try to use the |
Yep, it's not yet been released: This was merged into master in May 2020. Black 19.10b0 was released in October 2019 (19.10 is yy.mm, see https://calver.org/). |
Ah I see.
When is the next release date?
…On Thu, 18 Jun 2020 at 21:42, Hugo van Kemenade ***@***.***> wrote:
Yep, it's not yet been released:
This was merged into master in May 2020.
Black 19.10b0 was released in October 2019 (19.10 is yy.mm, see
https://calver.org/).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1266 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACFDBU2KZYGPRHBVJZGOPULRXIDS7ANCNFSM4KRUYVJQ>
.
|
I think it's coming sooner rather than later! #517 is the tracking issue, and see #517 (comment) and https://github.com/psf/black/labels/stable. |
GitHub master or even a branch is basically released these days. Introducing your new friend if you're in a hurry for color: pip install git+https://github.com/psf/black.git@master cooper-mbp1:~ cooper$ /tmp/tb/bin/black --help | grep color
--color / --no-color Show colored diff. Only applies when |
Awesome. Thanks for the help @cooperlees. I'm trying to set up a workflow for a new team project and I was comparing between Pylint vs Black vs Yapf. Not sure which is the best, but the color coded diffs of Black would definitely make a lot of difference. |
Fixes #994.
This adds a
--color
option to the black command line which adds very basic color support when printing diffs.git diff
because why not. Headers are Bold White, line markers Cyan, subtractions Red, and additions Green.--color
has no effect if--diff
is not supplied.Example:
Discussion
colorama
package should be included. I'm not sure how you feel about adding packages all willy-nilly, so I figured the first version of this PR would not include it.COLOR_DIFF
toWriteBack
because that meant I didn't have to change any call signatures.--color
which let the user choose betweenalways
,none
, andauto
. This is still doable, but will take more effort. Personally I don't much see the need for it - using a boolean is sufficient in my opinion. That said, if you'd like me to pursue it just let me know.