Skip to content

Commit 6264093

Browse files
committed
Create MypyXdistControllerPlugin
1 parent 8008632 commit 6264093

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/pytest_mypy.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ def _is_xdist_controller(config):
8383
return _get_xdist_workerinput(config) is None
8484

8585

86+
class MypyXdistControllerPlugin:
87+
"""A plugin that is only registered on xdist controller processes."""
88+
89+
def pytest_configure_node(self, node):
90+
"""Pass the config stash to workers."""
91+
_get_xdist_workerinput(node)["mypy_config_stash_serialized"] = (
92+
node.config.stash[stash_key["config"]].serialized()
93+
)
94+
95+
8696
def pytest_configure(config):
8797
"""
8898
Initialize the path used to cache mypy results,
@@ -105,15 +115,7 @@ def pytest_configure(config):
105115
# If xdist is enabled, then the results path should be exposed to
106116
# the workers so that they know where to read parsed results from.
107117
if config.pluginmanager.getplugin("xdist"):
108-
109-
class _MypyXdistPlugin:
110-
def pytest_configure_node(self, node): # xdist hook
111-
"""Pass the mypy results path to workers."""
112-
_get_xdist_workerinput(node)["mypy_config_stash_serialized"] = (
113-
node.config.stash[stash_key["config"]].serialized()
114-
)
115-
116-
config.pluginmanager.register(_MypyXdistPlugin())
118+
config.pluginmanager.register(MypyXdistControllerPlugin())
117119

118120
config.addinivalue_line(
119121
"markers",

0 commit comments

Comments
 (0)