Thanks to visit codestin.com
Credit goes to github.com

Skip to content

--color-output doesn't work #18746

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

Closed
bluenote10 opened this issue Feb 28, 2025 · 3 comments
Closed

--color-output doesn't work #18746

bluenote10 opened this issue Feb 28, 2025 · 3 comments
Labels
bug mypy got something wrong

Comments

@bluenote10
Copy link
Contributor

bluenote10 commented Feb 28, 2025

Bug Report

Using mypy --color-output does not seem to have any effect.

To Reproduce

$ mypy --color-output . | cat

Expected Behavior

This should produce a colored output, because --color-output suggests that colors are enforced. It should look like this (if I omit the | cat):

Image

Actual Behavior

Output is not colored.

Image

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags: --color-output
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.12.3

May have a similar cause as #13817. EDIT: actually, I no longer think so because FORCE_COLOR and MYPY_FORCE_COLOR works under _some_conditions (if the check I've mentioned there passes, which is not the case in e.g. GitHub or Gitlab), but --color-output never seems to have an effect for me.

@bluenote10 bluenote10 added the bug mypy got something wrong label Feb 28, 2025
@ilevkivskyi
Copy link
Member

This is expected behavior (similar to many other CLI tools btw). By default --color-output mode is auto, i.e. it will use color if isatty() returns True, which is never the case for pipes.

@ilevkivskyi ilevkivskyi closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2025
@bluenote10
Copy link
Contributor Author

bluenote10 commented Mar 3, 2025

@ilevkivskyi To me the docstring was suggestion something else, but yes it is not very clear:

  --no-color-output         Do not colorize error messages (inverse: --color-
                            output)

To me the inverse of forcing color off would be forcing color on. Also just, the imperative wording "color output" very much sounds like "force" to me. I'm literally telling mypy to color the output, not --color-output-if-possible.

This raises the question what effect --color-output actually has, because without specifying anything, the logic uses auto-detection anyway, right? So doesn't that mean that --color-output is a command line argument that does nothing?

My expectation was that --color-output is more like the common --color=yes or --color=always, which add meaningful functionality, because they allow turning off the auto-detection, and enforcing colors. This is basically something most other tools offer in one way or another. Here for instance in the example of pytest:

Image

Should I instead open a feature request for that?

@hepcat72
Copy link

I agree. Supplying --color-output should mean: I don't care whether I'm in a tty or not: output in color. --no-color-output should mean: I don't care whether I'm in a tty or not: do not output in color. Not supplying either should mean: output in color if this is a tty, otherwise don't output in color. Otherwise supplying --color-output is no different from not supplying either argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants