Skip to content

Commit aae3799

Browse files
committed
Add exception handler to deal with proxy object attrs as well
1 parent 24895d0 commit aae3799

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/pluggy/_manager.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,16 @@ 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+
method: object
197+
try:
198+
method = getattr(plugin, name)
199+
except AttributeError:
200+
# AttributeError: '__signature__' attribute of 'Plugin' is class-only
201+
# can happen for some special objects (e.g. proxies, pydantic, etc.)
202+
method = getattr(type(plugin), name) # use class sig instead
203+
199204
if not inspect.isroutine(method):
200205
return None
201206
try:

0 commit comments

Comments
 (0)