@@ -84,6 +84,11 @@ def pytest_addoption(parser: pytest.Parser) -> None:
84
84
type = str ,
85
85
help = "adds custom mypy config file" ,
86
86
)
87
+ group .addoption (
88
+ "--mypy-no-status-check" ,
89
+ action = "store_true" ,
90
+ help = "ignore mypy's exit status" ,
91
+ )
87
92
88
93
89
94
def _xdist_worker (config : pytest .Config ) -> Dict [str , Any ]:
@@ -164,6 +169,7 @@ def pytest_collect_file(
164
169
parent .config .option .mypy ,
165
170
parent .config .option .mypy_config_file ,
166
171
parent .config .option .mypy_ignore_missing_imports ,
172
+ parent .config .option .mypy_no_status_check ,
167
173
],
168
174
):
169
175
# Do not create MypyFile instance for a .py file if a
@@ -183,7 +189,9 @@ def collect(self) -> Iterator[MypyItem]:
183
189
# Since mypy might check files that were not collected,
184
190
# pytest could pass even though mypy failed!
185
191
# To prevent that, add an explicit check for the mypy exit status.
186
- if not any (isinstance (item , MypyStatusItem ) for item in self .session .items ):
192
+ if not self .session .config .option .mypy_no_status_check and not any (
193
+ isinstance (item , MypyStatusItem ) for item in self .session .items
194
+ ):
187
195
yield MypyStatusItem .from_parent (
188
196
parent = self ,
189
197
name = nodeid_name + "-status" ,
0 commit comments