Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Defaulted positional-only hook parameters are forwarded as keywords

Aperta
#774 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@adenzhou1350 ci sta già lavorando.

Dal 11/10/2026.

  • #775 di @adenzhou1350 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
tooling

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pluggy

Tutte le issue di pytest-dev/pluggy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.