Skip to content

Commit 0fcbb07

Browse files
authored
Add exception handler to deal with proxy object attrs as well
1 parent 24895d0 commit 0fcbb07

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/pluggy/_manager.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,15 @@ def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookimplOpts | None
191191
# pydantic model fields are like attrs and also can never be hookimpls
192192
plugin_is_pydantic_obj = hasattr(plugin, "__pydantic_core_schema__")
193193
if plugin_is_pydantic_obj and name in getattr(plugin, "model_fields", {}):
194-
# pydantic models mess with the class and attr __signature__
195-
# so inspect.isroutine(...) throws exceptions and cant be used
196194
return None
197195

198-
method: object = getattr(plugin, name)
196+
try:
197+
method: object = getattr(plugin, name)
198+
except AttributeError:
199+
# AttributeError: '__signature__' attribute of 'Plugin' is class-only
200+
# can happen for some special objects (e.g. proxies, pydantic, etc.)
201+
method: object = getattr(type(plugin), name) # use class sig instead
202+
199203
if not inspect.isroutine(method):
200204
return None
201205
try:

0 commit comments

Comments
 (0)