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.
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.
zsol
left a comment
There was a problem hiding this comment.
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
--coloroption to the black command line which adds very basic color support when printing diffs.git diffbecause why not. Headers are Bold White, line markers Cyan, subtractions Red, and additions Green.--colorhas no effect if--diffis not supplied.Example:
Discussion
coloramapackage 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_DIFFtoWriteBackbecause that meant I didn't have to change any call signatures.--colorwhich 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.