Status: Markers emit new types only Depends on: 02-configuration-objects.md Next: 04-hookimpl-wrapper-types.md Also unlocks: 06-project-spec.md
Markers on main attach dicts. After doc 02, configuration classes exist;
markers and discovery must use them exclusively.
HookspecMarker/HookimplMarkerattachHookspecConfiguration/HookimplConfigurationas<project>_spec/<project>_impl.HookSpecstoresconfig: HookspecConfiguration.- Manager parsing reads configuration objects only (no dict branch except calling the pytest mapping shim if an explicit compat path is required).
- ProjectSpec on markers (doc 06) — optional to combine.
- Impl subclass factory (doc 04).
def setattr_hookspec_opts(func: _F) -> _F:
config = HookspecConfiguration(
firstresult=firstresult,
historic=historic,
warn_on_impl=warn_on_impl,
warn_on_impl_args=warn_on_impl_args,
)
setattr(func, self.project_name + "_spec", config)
return func
def setattr_hookimpl_opts(func: _F) -> _F:
config = HookimplConfiguration(...)
setattr(func, self.project_name + "_impl", config)
return funcDecorator kwargs unchanged. Attribute value type is configuration object.
sequenceDiagram
participant Dev
participant Marker as HookimplMarker
participant Func as function
participant PM as PluginManager
Dev->>Marker: "@hookimpl(tryfirst=True)"
Marker->>Func: "project_impl = HookimplConfiguration"
Dev->>PM: register(plugin)
PM->>Func: getattr config
Note over PM: no dict path
git show try-claude:src/pluggy/_hook_markers.py
git show try-claude:src/pluggy/_manager.py- Update markers to construct/attach configuration objects.
- Update
HookSpecand manager discovery to use.firstresultetc. - Remove any
normalize_hookimpl_optsdict mutation on the live path. - Tests: attached attr is configuration instance; historic+firstresult raises at decoration time.
uv run pytest && uv run pre-commit run -aCommit message:
feat(decorators): attach Hook*Configuration objects on marked functions
- Decorator kwargs stable.
- Private attribute payload is now a configuration object (not a dict).
- Callers that poked dict attrs must use the pytest mapping shim or migrate.
| File | Coverage |
|---|---|
testing/test_configuration.py |
Attachment + validation |
| Registration / marker tests | Adapt off dict assumptions |
- No marker or manager live path attaches/reads TypedDicts.
- Suite green.