Skip to content
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 print absolute file paths #7754

Merged
merged 1 commit into from Oct 22, 2019

Conversation

@maksbotan
Copy link
Contributor

maksbotan commented Oct 19, 2019

It is a common use case to integrate mypy into an IDE or other
environment where it's run automatically and its output is processed by
other programs instead of being read by a human.

IDEs usually are able to parse paths, lines and messages printed by mypy
and show those messages directly in their code editor right under
affected lines.

However, some IDEs, like PyCharm, support reading only absolute file
paths from tools' output.

For example, there is an issue in PyCharm's issue tracker asking for a
way to read relative paths from tools:
https://youtrack.jetbrains.com/issue/IDEA-48163

Sadly, that issue did not receive any action for 11 years already,
apparently. And there is a comment from someone saying that mypy is
affected by this problem, not having any way to force absolute paths in
the output.

This commit adds a new option, --show-absolute-path, to fix exactly
this, with a straightforward implementation. I believe that this simple
fix will bring considerable benefits to PyCharm users and potentially
other people as well.

It is a common use case to integrate mypy into an IDE or other
environment where it's run automatically and its output is processed by
other programs instead of being read by a human.

IDEs usually are able to parse paths, lines and messages printed by mypy
and show those messages directly in their code editor right under
affected lines.

However, some IDEs, like PyCharm, support reading only absolute file
paths from tools' output.

For example, there is an issue in PyCharm's issue tracker asking for a
way to read relative paths from tools:
https://youtrack.jetbrains.com/issue/IDEA-48163

Sadly, that issue did not receive any action for 11 years already,
apparently. And there is a comment from someone saying that mypy is
affected by this problem, not having any way to force absolute paths in
the output.

This commit adds a new option, --show-absolute-path, to fix exactly
this, with a straightforward implementation. I believe that this simple
fix will bring considerable benefits to PyCharm users and potentially
other people as well.
@ilevkivskyi

This comment has been minimized.

Copy link
Collaborator

ilevkivskyi commented Oct 19, 2019

It is however trivial to work around this problem, since PyCharm knows project root itself, see e.g. https://github.com/dropbox/mypy-PyCharm-plugin. I am however not against this if other people would like to have this flag.

@maksbotan

This comment has been minimized.

Copy link
Contributor Author

maksbotan commented Oct 20, 2019

Well, I would say that a third-party plugin with a complicated installation procedure for Python beginners with no Java experience is not exactly a good solution to the such a simple task.

Moreover, your plugin shows a list of errors, but with an "Output Filter" PyCharm will show errors on lines with them, so that developer does not have to look away from the code to see errors. In my opinion, this is better user experience.

@maksbotan

This comment has been minimized.

Copy link
Contributor Author

maksbotan commented Oct 22, 2019

So, what is your opinion. I still think this feature is useful and does no harm.

By the way, PyCharm is not the only tool out there. I suppose that this could be also in some CI workflows to simplify things.

Copy link
Collaborator

msullivan left a comment

Yeah sure

@msullivan msullivan merged commit 4d332c5 into python:master Oct 22, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.