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
Maybe someone already noticed this, but IMO mypy is a bit "grumpy". Currently mypy never says anything good to a user. If there are no errors, then the output is just empty. This can even cause some confusion for a new user trying it on a simple clean file.
What do you think about emitting a simple message like Success: no issues found if there are no errors/notes emitted during type checking?
Btw, we can also optionally add a summary line if there are errors saying something like N issues found in M files. I often want to check how many errors there are and this forces me to re-run mypy with | grep error | wc -l.
Reacted by Mirko Bez, Emma Smith, Mateusz Bysiek, Leah Einhorn, Caleb Stanford and Juan Gabriel MEJIA
Yes, our internal wrappers add a success message, and I didn't hear anyone complaining about this.
I think an important part of reality that we need to accept is that although mypy was intended as a (relatively) advanced tool, it is in fact used a lot by novice programmers.
I don't have a strong opinion about this, but at least printing something when there is nothing to report might help new users. It could also be useful to print something like "no issues found in 35 files". One possible failure mode is accidentally checking only a small number of files, when imports aren't being followed.
I think it would make sense to do a quick survey of what other popular developer tools report on success (both Python and non-Python tools).
$ pylint setup.py
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
$ flake8 setup.py
$ black setup.py
All done! ✨ 🍰 ✨
1 file left unchanged.
Another reason for preferring a success/summary message is that otherwise multiple mypy runs can be hard to distinguish in a terminal. Here's an actual example:
(mypy) jukka mypy $ ./chk.sh
mypy/mypy/checker.py:3797: error: Unexpected keyword argument "code" for "report_protocol_problems" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1135: note: "report_protocol_problems" of "MessageBuilder" defined here
mypy/mypy/checker.py:3801: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
mypy/mypy/checker.py:3806: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
(mypy) jukka mypy $ ./chk.sh
mypy/mypy/messages.py:1208: error: Unexpected keyword argument "code" for "pretty_overload" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1214: error: Unexpected keyword argument "code" for "pretty_overload" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1215: error: Unexpected keyword argument "code" for "print_more" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1240: error: Unexpected keyword argument "code" for "print_more" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1242: note: "pretty_overload" of "MessageBuilder" defined here
mypy/mypy/messages.py:1287: note: "print_more" of "MessageBuilder" defined here
mypy/mypy/checker.py:3797: error: Argument "code" to "report_protocol_problems" of "MessageBuilder" has incompatible type "Optional[ErrorCode]"; expected "ErrorCode" [arg-type]
mypy/mypy/checker.py:3801: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
mypy/mypy/checker.py:3806: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
mypy/mypy/checkexpr.py:1335: error: Too few arguments for "report_protocol_problems" of "MessageBuilder" [call-arg]
(mypy) jukka mypy $
Here's the same with a summary message:
(mypy) jukka mypy $ ./chk.sh
mypy/mypy/checker.py:3797: error: Unexpected keyword argument "code" for "report_protocol_problems" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1135: note: "report_protocol_problems" of "MessageBuilder" defined here
mypy/mypy/checker.py:3801: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
mypy/mypy/checker.py:3806: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
3 errors in 1 file
(mypy) jukka mypy $ ./chk.sh
mypy/mypy/messages.py:1208: error: Unexpected keyword argument "code" for "pretty_overload" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1214: error: Unexpected keyword argument "code" for "pretty_overload" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1215: error: Unexpected keyword argument "code" for "print_more" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1240: error: Unexpected keyword argument "code" for "print_more" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1242: note: "pretty_overload" of "MessageBuilder" defined here
mypy/mypy/messages.py:1287: note: "print_more" of "MessageBuilder" defined here
mypy/mypy/checker.py:3797: error: Argument "code" to "report_protocol_problems" of "MessageBuilder" has incompatible type "Optional[ErrorCode]"; expected "ErrorCode" [arg-type]
mypy/mypy/checker.py:3801: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
mypy/mypy/checker.py:3806: error: Unexpected keyword argument "code" for "note_call" of "MessageBuilder" [call-arg]
mypy/mypy/messages.py:1102: note: "note_call" of "MessageBuilder" defined here
mypy/mypy/checkexpr.py:1335: error: Too few arguments for "report_protocol_problems" of "MessageBuilder" [call-arg]
8 errors in 3 files
(mypy) jukka mypy $
I think that it's easier to see where the new run beings in the second example. Colors (#7410) would also help with this.
Activity
msullivan commentedon Aug 21, 2019
My gut inclination is for silence in the success case. (Although certainly our internal wrapper scripts are all very noisy?)
ilevkivskyi commentedon Aug 22, 2019
@msullivan
JukkaL commentedon Aug 26, 2019
I don't have a strong opinion about this, but at least printing something when there is nothing to report might help new users. It could also be useful to print something like "no issues found in 35 files". One possible failure mode is accidentally checking only a small number of files, when imports aren't being followed.
I think it would make sense to do a quick survey of what other popular developer tools report on success (both Python and non-Python tools).
JelleZijlstra commentedon Aug 26, 2019
Here are a few:
JukkaL commentedon Aug 29, 2019
Another reason for preferring a success/summary message is that otherwise multiple mypy runs can be hard to distinguish in a terminal. Here's an actual example:
Here's the same with a summary message:
I think that it's easier to see where the new run beings in the second example. Colors (#7410) would also help with this.
Add support for nicer error output (#7425)
snowyurik commentedon Dec 26, 2022
That's worst idea ever. How I am supposed to use mypy in CI/CD now???????????? Please undo it