duncan­lock­.net

The Python Black formatter outputs to stderr, not stdout

Which is fine - it’s reporting errors, after all. So, if you want to capture the output to a file in Linux/Bash, you need to do it like this:

$ black --check . 2> black-report.txt

or like this to also output to the console, so you can see it:

$ black --check . 2> >(tee -a black-report.txt >&2)

Bash has a shortcut for this, but you lose the return code from black:

$ black --check . |& tee black-report.txt

References


Related Posts