-
Notifications
You must be signed in to change notification settings - Fork 13.3k
tidy: Make errors be printed in red and underlined #18826
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
Conversation
Sadly I think that this is a unix-only-ism and may not work on windows, do you know if python translates this under the hood for windows? |
@alexcrichton No. I bet there is some package on PyPI that does it but I don't know of one off the top of my head. OTOH this is just a Lint tool, even if it does not work all that will change is that something like "?[4;31m" will be printed before the error and "[0m" will be printed after it, which doesn't seem like all that bad an outcome considering it will help most people... |
@scialex I think https://pypi.python.org/pypi/colorama is what you have in mind. But for now we should be able to detect if we can print colours with https://docs.python.org/3/library/curses.html#curses.has_colors. r=me with that change. |
@jakub- that won't work. Starting up curses clears the screen, which would somewhat defeat the purpose. It would also totally kill things like the travis, which rely on pipes working intelligently. |
We print colors elsewhere, so surely this shouldn't be blocked on that. If the problem is underlining, then I'd be fine removing the underlining and keeping the color. Even without the underline it stands out quite nicely. Or am I misunderstanding how we handle color? |
I believe that all of our color printing from the compiler at least will perform detection of support at runtime. Not all shells work by printing these escapes (notably windows ones don't), and the compiler detects the best way to do so. If there was an easy way to guard this for only shells that support this form of colorization, then that would be great! |
Using the I'm not sure if Windows console is supported, but we can probably check with the |
@nodakai No what we really need is something like https://pypi.python.org/pypi/colorama as @jakub- suggested. The problem with using curses is that is screws up piping if we aren't very careful, which would kill travis. |
Ah, I overlooked @jakub- already mentioned So we have two issues:
Because of 2, we need to programatically switch on/off terminal coloring depending on the result of In my previous comment, I almost suggested to disable terminal coloring on Windows by simply checking |
Closing due to inactivity, but feel free to reopen with the windows issues addressed! |
fix: Clear flycheck diagnostics per package properly
This is what it looks like with this patch
