Skip to content

Commit 8da5891

Browse files
nightcitybladenightcityblade
andauthored
docs: clarify hook implementation default arguments (#675)
Co-authored-by: nightcityblade <nightcityblade@gmail.com>
1 parent ab1d07e commit 8da5891

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

changelog/522.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document that hook implementation arguments with default values are not passed by pluggy.

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@ To allow for *hookspecs* to evolve over the lifetime of a project,
570570
This allows for extending hook arguments (and thus semantics) without
571571
breaking existing *hookimpls*.
572572

573+
Only arguments without default values are considered for this opt-in
574+
matching. Arguments with defaults in a *hookimpl* are treated as optional
575+
keyword arguments and are not passed by pluggy, even when the hook caller
576+
provides a value with the same name. If a *hookimpl* needs a value from the
577+
hook call, declare it without a default value.
578+
573579
In other words this is ok:
574580

575581
.. code-block:: python

0 commit comments

Comments
 (0)