-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Suggestion: write messages to stdout instead of stderr #1051
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
Comments
I'm really -1 on this. Literally every static type checker or compiler I know uses |
I think it's an old tradition, but for something that doesn't produce
anything on stdout it feels pretty silly. FWIW pylint, pep8 and flake8 also
writes to stdout, so I think we'd actually be in good company.
Apart from tradition, why are you against this? What use case would this
inconvenience?
|
I'm okay with changing this. If mypy would behave like pylint, flake8 in this respect it probably wouldn't be surprising for most users. But I guess we could ask more people about their opinion if this is a controversial issue -- maybe there are some valid reasons for keeping the current behavior. |
I'm with Guido on this one. Apart from Python linters writing to stdout - I usually write things that are part of normal program operation to stdout (and in this context most of mypy's output is part of normal operation), and truly erroneous things like stack traces and parse errors to sderr. This way i can grep for specific outputs with ease, and most importantly, if something horrible happens, it would not disappear if grep does not include it. Here's how i would imagine it working:
|
Yeah, that would be ideal. Unfortunately the way the parser errors are On Sun, Dec 6, 2015 at 12:58 AM, Darjus Loktevic [email protected]
--Guido van Rossum (python.org/~guido) |
I'm not too familiar with mypy codebase yet but could we use standard python logging facilities? I remember seeing an issue where Jukka discusses warning messages and that currently everything's an error in mypy and it would be useful to support both. By using logging and handlers we could support this quite easily and could give extra flexibility on what to print where/when.
|
IMO the logging module isn't really meant for this use case. We want the On Sun, Dec 6, 2015 at 6:11 PM, Darjus Loktevic [email protected]
--Guido van Rossum (python.org/~guido) |
You're right, with different possible reporting output types it would be preferable to have pluggable outputs. Anyway, sorry for the detour :) https://bitbucket.org/logilab/pylint/src/4e5a1be18df2/pylint/reporters/?at=default |
Looks like this was broken again by a978ec0. I'll fix it by adding a flag to CompileError which will be set only when it's raised from Errors.raise_error(). |
I often want to grep mypy's output for certain messages (or to strip certain messages) and this is a little tricky because the messages are written to stderr. So I have to do e.g.
instead of
I think the only things that should be written to stderr are command line syntax errors (where it refuses to run) or fatal errors like tracebacks. Syntax errors in the modules to be analyzed should probably go to stdout (though since these abort processing it might be okay to send these to stderr).
Also -h output should go to stdout IMO (this is how argparse does things -- it would also be nice to rewrite the argument parsing using argparse).
The text was updated successfully, but these errors were encountered: