I just noticed that unlike black the colored output is not stripped in redirected output, which might look a bit strange if the pager does not interpret the color codes. The typical way to fix this is by checking if sys.stdout (or sys.stderr, if we're writing to that) is connected to a TTY using os.isatty().
I just noticed that unlike
black
the colored output is not stripped in redirected output, which might look a bit strange if the pager does not interpret the color codes. The typical way to fix this is by checking ifsys.stdout
(orsys.stderr
, if we're writing to that) is connected to a TTY usingos.isatty()
.