Add option to print absolute file paths #7754
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.