Closed
Description
Now that mypy can usually report the column number of errors in a useful manner, we could print out the contents of the source line for each error and underline the token the error points to (based on line/column information). This can be either enabled by default or through a flag -- I'm not sure which option I'd prefer yet.
Arguments for doing this:
- This makes it easier to see what is wrong, especially if the error message happens to be terse, or if there is a lot of things going on in a single line.
- Consistency with Python: Python tracebacks show the source line.
- Not everybody has configured their editor to highlight the location of the error.
- If a user edits the file with the error, the line number will get out of alignment. Having the source line in the output makes it easier to see where the error points to even if there have been edits.
- Many other tools can do this, so many users are used to this behavior.
Arguments for not doing this (at least by default):
- The length of mypy output is increased significantly. If we show a source line and a separate line with underlining, the number of lines may increase by a factor of three.
- The output may be harder to scan or look noisy, since there will be more stuff. Using colors should help with this (Use colors in mypy output #7410).
- If the reported line/column number is not logically correct, this may be confusing. We may want to fix the line/column numbers of most errors first. (I've already done some of this relatively recently.)
Thoughts?