realpython / pytest-mypy

Mypy static type checker plugin for Pytest
https://pypi.org/project/pytest-mypy/
MIT License
248 stars 32 forks source link

mypy 0.990 does not find any errors #142

Closed dmtucker closed 1 year ago

dmtucker commented 1 year ago

tox -e py310-pytest7.x-mypy0.9x is currently failing 15 tests:

15 failed, 32 passed, 6 xfailed, 18 warnings in 56.12s

(Warnings are https://github.com/pytest-dev/pytest-cov/issues/561.)

This diff seems to fix it:

diff --git a/src/pytest_mypy.py b/src/pytest_mypy.py
index d067925..fd1ba4d 100644
--- a/src/pytest_mypy.py
+++ b/src/pytest_mypy.py
@@ -262,7 +262,9 @@ class MypyResults:
             os.path.abspath(str(item.fspath)): [] for item in items
         }  # type: MypyResults._abspath_errors_type

-        stdout, stderr, status = mypy.api.run(opts + list(abspath_errors))
+        stdout, stderr, status = mypy.api.run(
+            opts + list(os.path.relpath(key) for key in abspath_errors.keys())
+        )

         unmatched_lines = []
         for line in stdout.split("\n"):

Because of that, I suspect https://github.com/python/mypy/issues/14042 is to blame.