Skip to content

Commit 8cbd593

Browse files
Remove legacy HookimplOpts normalization and from_opts method
- Remove normalize_hookimpl_opts function as modern pluggy uses HookimplConfiguration directly - Remove HookimplConfiguration.from_opts class method (backward compatibility no longer needed) - Simplify _parse_hookimpl method by removing dict-based configuration handling - Use HookimplConfiguration constructor directly instead of factory method - Maintain compatibility with parse_hookimpl_opts override for subclasses like pytest - Remove unnecessary normalize_hookimpl_opts import from _manager.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 809621a commit 8cbd593

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

src/pluggy/_hooks.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ def __init__(
137137
#: The name of the hook specification to match, see :ref:`specname`.
138138
self.specname: Final = specname
139139

140-
@classmethod
141-
def from_opts(cls, opts: HookimplOpts) -> HookimplConfiguration:
142-
"""Create from HookimplOpts for backward compatibility."""
143-
return cls(**opts)
144-
145140
def __repr__(self) -> str:
146141
attrs = []
147142
for slot in self.__slots__:
@@ -385,15 +380,6 @@ def get_hookconfig(self, func: Callable[..., object]) -> HookimplConfiguration:
385380
return config
386381

387382

388-
def normalize_hookimpl_opts(opts: HookimplOpts) -> None:
389-
opts.setdefault("tryfirst", False)
390-
opts.setdefault("trylast", False)
391-
opts.setdefault("wrapper", False)
392-
opts.setdefault("hookwrapper", False)
393-
opts.setdefault("optionalhook", False)
394-
opts.setdefault("specname", None)
395-
396-
397383
_PYPY = hasattr(sys, "pypy_version_info")
398384

399385

src/pluggy/_manager.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from ._hooks import HookimplOpts
2626
from ._hooks import HookRelay
2727
from ._hooks import HookspecOpts
28-
from ._hooks import normalize_hookimpl_opts
2928
from ._result import Result
3029

3130

@@ -185,9 +184,6 @@ def _parse_hookimpl(
185184
) -> HookimplConfiguration | None:
186185
"""Internal method to parse hook implementation configuration.
187186
188-
This method uses the new HookimplConfiguration type internally.
189-
Falls back to the legacy parse_hookimpl_opts method for compatibility.
190-
191187
:param plugin: The plugin object to inspect
192188
:param name: The attribute name to check for hook implementation
193189
:returns: HookimplConfiguration if found, None otherwise
@@ -201,25 +197,19 @@ def _parse_hookimpl(
201197
return None
202198

203199
try:
204-
# Try to get hook implementation configuration directly
200+
# Get hook implementation configuration directly
205201
impl_attr = getattr(method, self.project_name + "_impl", None)
206202
except Exception: # pragma: no cover
207203
impl_attr = None
208204

209-
if impl_attr is not None:
210-
# Check if it's already a HookimplConfiguration (new style)
211-
if isinstance(impl_attr, HookimplConfiguration):
212-
return impl_attr
213-
# Handle legacy dict-based configuration
214-
elif isinstance(impl_attr, dict):
215-
return HookimplConfiguration.from_opts(impl_attr) # type: ignore
205+
if isinstance(impl_attr, HookimplConfiguration):
206+
return impl_attr
216207

217208
# Fall back to legacy parse_hookimpl_opts for compatibility
218209
# (e.g. pytest override)
219210
legacy_opts = self.parse_hookimpl_opts(plugin, name)
220211
if legacy_opts is not None:
221-
normalize_hookimpl_opts(legacy_opts)
222-
return HookimplConfiguration.from_opts(legacy_opts)
212+
return HookimplConfiguration(**legacy_opts)
223213

224214
return None
225215

0 commit comments

Comments
 (0)