pyupio/safety

Output includes ANSI escape sequences when inappropriate

stevecj opened this issue · 3 comments

  • safety version: 2.2.0
  • Python version: 3.9.6
  • Operating System: Linux: CentOS 7

Description

Printing full report output in a CI test run prints ANSI codes, even though the environment does not indicate that ANSI color is appropriate. I also tried piping the output through less, and commands should, by default, not include ANSI codes in output when piped (stdout is not a terminal). I tried running with TERM set to "dumb" instead of "xterm-256color" and with CLICOLOR set to "0". None of that convinced safety to not print the ANSI escape sequences.

I finally realized that I could get a list of options for the check subcommand with safety check --help and was able to figure out by trial and error that --output text will eliminate the ansi codes from the output. It would still be nice if safety would automatically not include escape codes in cases where commandline apps are supposed to know to omit them.

Hi @stevecj, we are sorry for your bad experience with the ANSI color and the documentation. We have tried to link our documentation in all the possible places; maybe we may add the docs link in Safety CI too.

You can find all the available outputs in the docs portal: https://docs.pyup.io/docs/safety-20-configuration-outputs.

We updated the docs portal to include the No Styling option. Safety reads an environment variable called SAFETY_COLOR, but in 2.2.0 and below, there is a bug reading that ENV var; The fix for the bug is in PR #412, so SAFETY_COLOR will be usable in the next release.

I agree with your recommendation, Safety should try to detect when the style is inappropriate, I'm going to keep this open.

I'm closing this issue because the latest Safety version supports the SAFETY_COLOR var. Trying to detect when using the style or text automatically will need another issue and more details.