File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ import os
1
4
import sys
2
5
3
6
import pytest
7
+ from pytest_mypy import MypyFileItem , MypyResults
4
8
5
9
pytest_plugins = 'setuptools.tests.fixtures'
6
10
@@ -20,7 +24,18 @@ def pytest_addoption(parser):
20
24
)
21
25
22
26
27
+ def mypy_error_formatter_show_filename (
28
+ item : MypyFileItem , results : MypyResults , errors : list [str ]
29
+ ) -> str : # pragma: nocover # This shouldn't run on success
30
+ """Include the relative file path before each reported error."""
31
+ return '\n ' .join (
32
+ f'{ item .path .relative_to (os .getcwd ())} :{ error } ' for error in errors
33
+ )
34
+
35
+
23
36
def pytest_configure (config ):
37
+ mypy_plugin = config .pluginmanager .getplugin ('mypy' )
38
+ mypy_plugin .file_error_formatter = mypy_error_formatter_show_filename
24
39
config .addinivalue_line ("markers" , "integration: integration tests" )
25
40
config .addinivalue_line ("markers" , "uses_network: tests may try to download files" )
26
41
_IntegrationTestSpeedups .disable_plugins_already_run (config )
You can’t perform that action at this time.
0 commit comments