-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add option to format the output messages #3547
Comments
Wow, there are IDEs that cannot keep track of the directory where they run simple tools like mypy? |
It's more concerned with the (in)ability to parse the output. There was a similar feature request for pylama that illustrates the issue (with PyCharm). Beyond that, and probably as a better general solution, I think that an option like pylint's |
Well, I have run into this in the past with PyCharm, but IMO this is really a PyCharm bug. The generalized solution sounds like something I'd like to avoid for a few more years. In the meantime I'm sure you can write a little bash script that munges the output the way youwant. |
Thanks! The bash script was written (awk at rescue): I cannot wait a few more years to integrate the useful mypy in the IDE 😉 . Anyway, that makes sense and I'll open an issue in PyCharm. |
When I run mypy with the full file path from PyCharm, the full file path is included in the output (and can be turned into a link) |
I couldn't get it to work as per @wbkdef For anyone else coming here looking for a solution to using this with PyCharm, You can use the following bash script to wrap mypy and munge the output. #!/bin/bash
MYPY_BIN=/usr/local/bin/mypy
length=$(($#-1))
mypyargs=${@:1:$length}
basepath=${@:$length+1:$length+1}
$MYPY_BIN $mypyargs | awk -v basepath=$basepath '{print basepath"/" $0}' Set up your PyCharm like this - note the additional argument on the end - this is used as a prefix to all output from mypy. |
Yes, making it work requires some tricks, and even when it works I was not very happy with the ergonomics. There is an "official" mypy PyCharm plugin that works smoother (at least for me) https://github.com/dropbox/mypy-PyCharm-plugin |
Something I didn't realize before, her is another thing I do that helps make mypy output the full path for each file: I run it in a directory totally unrelated to my project. I see @switchtrue is running it in the "ProjectFileDir", and so mypy uses a relative path. Here's a screenshot of my setup (I'm also running mypy with a python script, that filters the output). |
For pycharm you can use this "external tool" setup:
|
I've made a new task that's pretty closely related to this - to add JSON output support. That should allow robust output parsing by IDEs, etc. See #10816. |
This is a feature request for easing the integration of mypy in some IDEs. The flag (suggested: abspath) would output the full path of the file just before
":{line_number}:[{column_number}:] error: ..."
. Of course, a more comprehensive solution would be a full formatter of the output lines with this and other choices to achieve the desired format in each case.The text was updated successfully, but these errors were encountered: