@@ -130,7 +130,7 @@ def pytest_configure(config: pytest.Config) -> None:
130
130
"""
131
131
xdist_worker = _xdist_worker (config )
132
132
if not xdist_worker :
133
- config .pluginmanager .register (MypyReportingPlugin ())
133
+ config .pluginmanager .register (MypyControllerPlugin ())
134
134
135
135
# Get the path to a temporary file and delete it.
136
136
# The first MypyItem to run will see the file does not exist,
@@ -372,15 +372,15 @@ class MypyWarning(pytest.PytestWarning):
372
372
"""A non-failure message regarding the mypy run."""
373
373
374
374
375
- class MypyReportingPlugin :
376
- """A Pytest plugin that reports mypy results ."""
375
+ class MypyControllerPlugin :
376
+ """A plugin that is not registered on xdist worker processes ."""
377
377
378
378
def pytest_terminal_summary (
379
379
self ,
380
380
terminalreporter : TerminalReporter ,
381
381
config : pytest .Config ,
382
382
) -> None :
383
- """Report stderr and unrecognized lines from stdout ."""
383
+ """Report mypy results ."""
384
384
mypy_results_path = config .stash [stash_key ["config" ]].mypy_results_path
385
385
try :
386
386
with open (mypy_results_path , mode = "r" ) as results_f :
@@ -397,4 +397,11 @@ def pytest_terminal_summary(
397
397
terminalreporter .write_line (results .unmatched_stdout , ** color )
398
398
if results .stderr :
399
399
terminalreporter .write_line (results .stderr , yellow = True )
400
- mypy_results_path .unlink ()
400
+
401
+ def pytest_unconfigure (self , config : pytest .Config ) -> None :
402
+ """Clean up the mypy results path."""
403
+ try :
404
+ config .stash [stash_key ["config" ]].mypy_results_path .unlink ()
405
+ except FileNotFoundError : # compat python < 3.8 (missing_ok=True)
406
+ # No MypyItems executed.
407
+ return
0 commit comments