Skip to content

Commit 9d8d198

Browse files
authored
Update _manager.py
1 parent 92a2f63 commit 9d8d198

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/pluggy/_manager.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,17 @@ def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookimplOpts | None
182182
options for items decorated with :class:`HookimplMarker`.
183183
"""
184184

185-
# IMPORTANT: accessing an @property can have side effects that we dont want to trigger
186-
# if attr is a property, skip it in advance (@property methods can never be hookimpls)
185+
# IMPORTANT: @property methods can have side effects, and are never hookimpl
186+
# if attr is a property, skip it in advance
187187
plugin_class = plugin if inspect.isclass(plugin) else type(plugin)
188188
if isinstance(getattr(plugin_class, name, None), property):
189189
return None
190190

191-
# if attr is field on a pydantic model, skip it (pydantic fields are never hookimpls)
192-
if hasattr(plugin, "__pydantic_core_schema__") and name in getattr(
193-
plugin, "model_fields", {}
194-
):
195-
# pydantic can present class attributes, instance attributes, or methods
196-
# but none of them can be hookimpls so they throw off the logic below
191+
# pydantic model fields are like attrs and also can never be hookimpls
192+
plugin_is_pydantic_obj = hasattr(plugin, "__pydantic_core_schema__")
193+
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
197196
return None
198197

199198
method: object = getattr(plugin, name)

0 commit comments

Comments
 (0)