Skip to content
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

Output includes ANSI escape sequences when inappropriate #408

Closed
stevecj opened this issue Sep 28, 2022 · 3 comments
Closed

Output includes ANSI escape sequences when inappropriate #408

stevecj opened this issue Sep 28, 2022 · 3 comments
Assignees

Comments

@stevecj
Copy link

stevecj commented Sep 28, 2022

  • 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.

@stevecj
Copy link
Author

stevecj commented Sep 28, 2022

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.

@yeisonvargasf yeisonvargasf self-assigned this Sep 29, 2022
@yeisonvargasf
Copy link
Member

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.

@yeisonvargasf
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants