@@ -170,12 +170,14 @@ def register(self, plugin: _Plugin, name: str | None = None) -> str | None:
170
170
hook ._add_hookimpl (hookimpl )
171
171
return plugin_name
172
172
173
- def _parse_hookimpl (self , plugin : _Plugin , name : str ) -> HookimplConfiguration | None :
173
+ def _parse_hookimpl (
174
+ self , plugin : _Plugin , name : str
175
+ ) -> HookimplConfiguration | None :
174
176
"""Internal method to parse hook implementation configuration.
175
-
177
+
176
178
This method uses the new HookimplConfiguration type internally.
177
179
Falls back to the legacy parse_hookimpl_opts method for compatibility.
178
-
180
+
179
181
:param plugin: The plugin object to inspect
180
182
:param name: The attribute name to check for hook implementation
181
183
:returns: HookimplConfiguration if found, None otherwise
@@ -184,30 +186,30 @@ def _parse_hookimpl(self, plugin: _Plugin, name: str) -> HookimplConfiguration |
184
186
method : object = getattr (plugin , name )
185
187
except Exception : # pragma: no cover
186
188
return None
187
-
189
+
188
190
if not inspect .isroutine (method ):
189
191
return None
190
-
192
+
191
193
try :
192
194
# Try to get hook implementation configuration directly
193
195
impl_attr = getattr (method , self .project_name + "_impl" , None )
194
196
except Exception : # pragma: no cover
195
197
impl_attr = None
196
-
198
+
197
199
if impl_attr is not None :
198
200
# Check if it's already a HookimplConfiguration (new style)
199
201
if isinstance (impl_attr , HookimplConfiguration ):
200
202
return impl_attr
201
203
# Handle legacy dict-based configuration
202
204
elif isinstance (impl_attr , dict ):
203
205
return HookimplConfiguration .from_opts (impl_attr )
204
-
206
+
205
207
# Fall back to legacy parse_hookimpl_opts for compatibility (e.g. pytest override)
206
208
legacy_opts = self .parse_hookimpl_opts (plugin , name )
207
209
if legacy_opts is not None :
208
210
normalize_hookimpl_opts (legacy_opts )
209
211
return HookimplConfiguration .from_opts (legacy_opts )
210
-
212
+
211
213
return None
212
214
213
215
def parse_hookimpl_opts (self , plugin : _Plugin , name : str ) -> HookimplOpts | None :
@@ -217,10 +219,10 @@ def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookimplOpts | None
217
219
:returns:
218
220
The parsed hookimpl options, or None to skip the given item.
219
221
220
- .. deprecated::
221
- Customizing hook implementation parsing by overriding this method is
222
- deprecated. This method is only kept as a compatibility shim for
223
- legacy projects like pytest. New code should use the standard
222
+ .. deprecated::
223
+ Customizing hook implementation parsing by overriding this method is
224
+ deprecated. This method is only kept as a compatibility shim for
225
+ legacy projects like pytest. New code should use the standard
224
226
:class:`HookimplMarker` decorators.
225
227
"""
226
228
# Compatibility shim - only overridden by legacy projects like pytest
0 commit comments