@@ -89,7 +89,8 @@ def pytest_configure(config):
89
89
register a custom marker for MypyItems,
90
90
and configure the plugin based on the CLI.
91
91
"""
92
- if not _xdist_worker (config ):
92
+ xdist_worker = _xdist_worker (config )
93
+ if not xdist_worker :
93
94
config .pluginmanager .register (MypyReportingPlugin ())
94
95
95
96
# Get the path to a temporary file and delete it.
@@ -106,6 +107,11 @@ def pytest_configure(config):
106
107
# the workers so that they know where to read parsed results from.
107
108
if config .pluginmanager .getplugin ("xdist" ):
108
109
config .pluginmanager .register (MypyXdistControllerPlugin ())
110
+ else :
111
+ # xdist workers create the stash using input from the controller plugin.
112
+ config .stash [stash_key ["config" ]] = MypyConfigStash .from_serialized (
113
+ xdist_worker ["input" ]["mypy_config_stash_serialized" ]
114
+ )
109
115
110
116
config .addinivalue_line (
111
117
"markers" ,
@@ -271,14 +277,7 @@ def from_mypy(
271
277
@classmethod
272
278
def from_session (cls , session ) -> "MypyResults" :
273
279
"""Load (or generate) cached mypy results for a pytest session."""
274
- xdist_worker = _xdist_worker (session .config )
275
- if not xdist_worker :
276
- mypy_config_stash = session .config .stash [stash_key ["config" ]]
277
- else :
278
- mypy_config_stash = MypyConfigStash .from_serialized (
279
- xdist_worker ["input" ]["mypy_config_stash_serialized" ]
280
- )
281
- mypy_results_path = mypy_config_stash .mypy_results_path
280
+ mypy_results_path = session .config .stash [stash_key ["config" ]].mypy_results_path
282
281
with FileLock (str (mypy_results_path ) + ".lock" ):
283
282
try :
284
283
with open (mypy_results_path , mode = "r" ) as results_f :
0 commit comments