call_extra() drops arguments for partial callbacks

未关闭
#817 0 条评论 0 个 reaction 已指派 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 分钟
30 天内合并 PR
13

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pytest-dev/pluggy 的其他 Issue

查看 pytest-dev/pluggy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。