Skip to content

Commit 54248d5

Browse files
committed
Add .plugin member to PluginValidationError to access failing plugin
1 parent ab41599 commit 54248d5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pluggy/manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
class PluginValidationError(Exception):
77
""" plugin failed validation. """
88

9+
def __init__(self, plugin, message):
10+
self.plugin = plugin
11+
super(Exception, self).__init__(message)
12+
913

1014
class PluginManager(object):
1115
""" Core Pluginmanager class which manages registration
@@ -178,13 +182,15 @@ def get_name(self, plugin):
178182
def _verify_hook(self, hook, hookimpl):
179183
if hook.is_historic() and hookimpl.hookwrapper:
180184
raise PluginValidationError(
185+
hookimpl.plugin,
181186
"Plugin %r\nhook %r\nhistoric incompatible to hookwrapper" %
182187
(hookimpl.plugin_name, hook.name))
183188

184189
# positional arg checking
185190
notinspec = set(hookimpl.argnames) - set(hook.argnames)
186191
if notinspec:
187192
raise PluginValidationError(
193+
hookimpl.plugin,
188194
"Plugin %r for hook %r\nhookimpl definition: %s\n"
189195
"Argument(s) %s are declared in the hookimpl but "
190196
"can not be found in the hookspec" %
@@ -202,6 +208,7 @@ def check_pending(self):
202208
for hookimpl in (hook._wrappers + hook._nonwrappers):
203209
if not hookimpl.optionalhook:
204210
raise PluginValidationError(
211+
hookimpl.plugin,
205212
"unknown hook %r in plugin %r" %
206213
(name, hookimpl.plugin))
207214

0 commit comments

Comments
 (0)