Remove MypyItem.mypy_path #59
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.
Fix #58
First, I attempted to fix
MypyItem.mypy_path
; however, Mypy wasn't very helpful, unfortunately.The problem is that the code it uses to calculate the path it ultimately displays is neither conveniently grouped nor exposed in the public API. I got a copy-pasta solution working (though, it is not fully covered) in 6464322, but concerns about the maintenance burden of trying to re-create what Mypy does under-the-hood (especially if that ever changes incompatibly) begged for another solution.
The primary reason for
MypyItem.mypy_path
is to match the path found in Mypy output to the appropriateMypyItem
. It is also used inreportinfo
, which is meant to reflect the path from Mypy output (e.g.foo
infoo:5: error: from mypy
).The first need can be satisfied (with
os.path.abspath
) by normalizing theMypyItem
and Mypy output paths before matching them. As forreportinfo
, the point of the header, IMO, is to clearly correspond to results produced by Pytest during a run. For example:Here we see an
F
in the output:The header should clearly allow me to associate the subsequent report with that
F
. This is a very simple example, but as the test run grows larger, I believe this becomes even more important. Pytest associates thatF
withsrc/pytest_mypy.py
(which seems to be calculated here: https://github.com/pytest-dev/pytest/blob/8ccc0177c8be85c0725981b3a9e867baeebfbe33/src/_pytest/terminal.py#L290). So, making that the header seems natural:Since
MypyItem.mypy_path
is technically public, this is a backwards-incompatible change, so it will target 0.5.0 instead of 0.4.2.