You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many development tools use color in their output these days, and I think that it's time that mypy did that as well. Arguments for using colors:
It's faster to scan error messages to find the relevant part.
Colored messages may subjectively feel/look better even if there is no concrete utility.
This is becoming a standard, like it or not.
My personal preference is to not go overboard and to use colors in a somewhat restrained manner. Also, I'd prefer to mostly stick to a few colors instead of using all the colors available.
There should be an option to explicitly disable colors. We may also want to disable colors automatically if the output is piped to another process. If we do this, we'd probably need an option to also force colors to be used.
(Originally discussed in #3439 but moved to a separate issue.)
The only issue I see is that the red messages are really the most "important" ones, but will be the hardest to read. Another option would just be to color the <file>:<line>: <status>: part and leave the message itself uncolored. On reflection, I actually like this option quite a bit.
Perhaps something would be needed for actual mypy errors/failure though...
I think that we don't want to color the entire message to maintain good readability. I think that some tools only color the status code, which may be a reasonable trade-off.
Surveying how/if various popular tools use colors would be interesting (and not only Python tools). Ideas:
Python linters
Cython
Compilers for various languages: TypeScript, Go, Rust, Java, C++
I like the idea of highlighting only error code (plus the summary line at the end). IIRC this is what Rust does (or used to do) apart from showing the source snippet with some notes. Actually it highlights both the status (i.e. word error), but it is different from mypy because the error code follows the status, like error[EXXXX].
Also I would like to highlight the note: in light blue or other light color.
I'm all for it, as long as it turns itself off if stdout is not a tty, and also if $TERM is dumb (or perhaps any value that doesn't have a defined termcap entry).
In terms of color scheme, let's make sure that it's readable both for dark themes and light themes.
I don't have strong preferences about what parts to highlight, just let's not invent the wheel and follow the lead of some other popular tools in the Python ecosystem. Maybe pylint -f colorized?
Activity
brandtbucher commentedon Aug 29, 2019
I would definitely appreciate a three-color scheme:
The only issue I see is that the red messages are really the most "important" ones, but will be the hardest to read. Another option would just be to color the
<file>:<line>: <status>:part and leave the message itself uncolored. On reflection, I actually like this option quite a bit.Perhaps something would be needed for actual mypy errors/failure though...
JukkaL commentedon Aug 29, 2019
I think that we don't want to color the entire message to maintain good readability. I think that some tools only color the status code, which may be a reasonable trade-off.
Surveying how/if various popular tools use colors would be interesting (and not only Python tools). Ideas:
ilevkivskyi commentedon Aug 29, 2019
I like the idea of highlighting only error code (plus the summary line at the end). IIRC this is what Rust does (or used to do) apart from showing the source snippet with some notes. Actually it highlights both the status (i.e. word
error), but it is different from mypy because the error code follows the status, likeerror[EXXXX].Also I would like to highlight the
note:in light blue or other light color.gvanrossum commentedon Aug 29, 2019
I'm all for it, as long as it turns itself off if stdout is not a tty, and also if $TERM is
dumb(or perhaps any value that doesn't have a defined termcap entry).In terms of color scheme, let's make sure that it's readable both for dark themes and light themes.
I don't have strong preferences about what parts to highlight, just let's not invent the wheel and follow the lead of some other popular tools in the Python ecosystem. Maybe
pylint -f colorized?gvanrossum commentedon Aug 29, 2019
Also, let's not get into bikeshedding. Let's just do it.
Add support for nicer error output (#7425)