Defaulted positional-only hook parameters are forwarded as keywords
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 1.7k
- Fork
- 172
- Merge medio
- 2g 18h
- PR unite (30g)
- 21
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytest-dev/pluggy
-
Plugin registry compares plugins by equality, not identityForse già presa @00200200 l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
pytest-dev/pluggy#760 ·
I maintainer di solito rispondono entro 1 giorno
-
list_plugin_distinfo() keeps unregistered pluginsForse già presa @RonnyPfannschmidt l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
pytest-dev/pluggy#763 ·
I maintainer di solito rispondono entro 1 giorno
-
unregister() argument validation relies on assertForse già presa @ekanshul l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 42/100
pytest-dev/pluggy#762 ·
I maintainer di solito rispondono entro 1 giorno
-
Failures during add_hookspecs / historic replay leave partial stateForse già presa @starx710 l’ha presa 1 giorno fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 50/100
pytest-dev/pluggy#761 ·
I maintainer di solito rispondono entro 1 giorno
-
[Downstream] devpi broken - trying to register `None`Forse già presa @bluetech l’ha presa 14 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
pytest-dev/pluggy#749 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pytest-dev/pluggy
Issue simili
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
btclib-org/btclib-node#1955 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation v0.9.2
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
khuisman/mcp-gee-sweet#1033 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ossf/cve-bin-tool#5966 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
write_iceberg ignores the table's write.parquet.compression-codec propertyForse già presa @YuangGao l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Eventual-Inc/Daft#7606 ·
I maintainer di solito rispondono entro 1 giorno