call_extra() drops arguments for partial callbacks

オープン
#817 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@HocVoNgThai がすでに取り組んでいます。

2026年11月1日 から。

  • #818 @HocVoNgThai による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
devtools

調査の方向性

Start with the reproducer in the issue, which uses HookCaller.call_extra() with a functools.partial callback. The problem is in varnames(), which reads the partial's own __call__ instead of its remaining signature, so the bound arguments are never forwarded. Run the snippet and confirm it returns [("demo", 7)], then check the existing varnames() tests for plain functions and partials.

索引モデルが issue の本文から書いたものです。

説明

Passing a functools.partial callback to HookCaller.call_extra() drops the remaining hook arguments. A callback with a required argument raises TypeError; one with a default silently uses that default instead of the supplied value.

from functools import partial
import pluggy

hookspec = pluggy.HookspecMarker("example")

class Hooks:
    @hookspec
    def event(self, value):
        pass

def on_event(context, value):
    return context, value

pm = pluggy.PluginManager("example")
pm.add_hookspecs(Hooks)
callback = partial(on_event, "demo")
assert callback(7) == ("demo", 7)
print(pm.hook.event.call_extra([callback], {"value": 7}))

Expected: [("demo", 7)].
Actual: TypeError: on_event() missing 1 required positional argument: 'value'.

varnames() inspects the partial's built-in __call__ rather than its remaining signature, so no parameters are forwarded.

Reproduced on Python 3.12.16/Linux with main 3fc9e561ea7e72a95549673d79ebdaf4a9fae829.

主要言語
Python
スター
1.7k
フォーク
200
平均マージ
10時間 4分
マージ済み PR(30日)
13

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytest-dev/pluggy のほかの issue

pytest-dev/pluggy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。