Defaulted positional-only hook parameters are forwarded as keywords
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start from the reproduction script in the issue: a hookimpl with a defaulted positional-only parameter, called as pm.hook.hello(value="caller"), currently raises a TypeError about positional-only arguments passed as keywords. Read how pluggy forwards hookimpl defaults and binds arguments for both old- and new-style wrappers, and check the explicit-value precedence described for #738. Done when the script prints ["caller"], a later optional positional-only argument leaves the earlier default intact, and the regression tests pass.
Written by the indexing model from the issue text.
Description
On current main 87f130aa18d8fdf9c92585e72423eca7f3de727d, the new hookimpl-default forwarding behavior passes defaulted positional-only arguments as keywords:
import pluggy
hookspec = pluggy.HookspecMarker("example")
hookimpl = pluggy.HookimplMarker("example")
class Spec:
@hookspec
def hello(self, value):
pass
class Plugin:
@hookimpl
def hello(self, value="fallback", /):
return value
pm = pluggy.PluginManager("example")
pm.add_hookspecs(Spec)
pm.register(Plugin())
print(pm.hook.hello(value="caller"))
Expected: ["caller"], following the explicit-value precedence introduced in #738. Actual: TypeError: ... got some positional-only arguments passed as keyword arguments: 'value'.
The same failure occurs in new- and old-style wrappers. Removing the default makes positional-only delivery work. If only a later optional positional-only argument is supplied, the earlier argument must retain its implementation default rather than shifting the supplied value.
Reproduced on native Windows and Linux CPython 3.12. The unmodified full suite passes 219 tests on both platforms; a focused added matrix has 13 failures and 9 passing controls on each. This concerns positional-only arguments, not the keyword-only API design in #742. I have a small fix and regression tests prepared.
AI assistance: OpenAI Codex; source inspection and native baseline/candidate tests were used to validate the finding.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 172
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pytest-dev/pluggy
-
Plugin registry compares plugins by equality, not identityPossibly taken @00200200 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
pytest-dev/pluggy#760 ·
Maintainers usually reply within 1 day
-
list_plugin_distinfo() keeps unregistered pluginsPossibly taken @RonnyPfannschmidt claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
pytest-dev/pluggy#763 ·
Maintainers usually reply within 1 day
-
unregister() argument validation relies on assertPossibly taken @ekanshul claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
pytest-dev/pluggy#762 ·
Maintainers usually reply within 1 day
-
Failures during add_hookspecs / historic replay leave partial statePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 50/100
pytest-dev/pluggy#761 ·
Maintainers usually reply within 1 day
-
[Downstream] devpi broken - trying to register `None`Possibly taken @bluetech claimed this 11 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
pytest-dev/pluggy#749 · 4 comments ·
Maintainers usually reply within 1 day
All issues in pytest-dev/pluggy
Similar issues
-
comp/gateway comp/plugins duplicate P3 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NousResearch/hermes-agent#137019 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bot-triaged module: docs triaged
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
new-entry
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BinWang28/audio-ai-hub#194 ·
-
confluence: a paged listing's links re-encode a parameter they carry, where real carries it as sentOpenfidelity
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day