Support cythonized hookspecs/hookimpls
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 71/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 pluggy/_manager.py 开始,阅读 _static_hook_attr,了解如何识别 hook 实现。Issue 提出了识别 Cython 函数对象的改动方案;检查现有 manager 测试中关于 hook 发现的部分,并为已编译的 hook 实现添加回归测试。回归测试通过且能够发现经过 Cython 编译的 hook,即表示完成。
由索引模型根据 Issue 内容生成。
描述
I have a project with hookimpls located in a .pyx module that is compiled to a native extension. With v1.7.0, the PluginManager doesn't discover the hookimpls in the compiled module, because inspect.isfunction() doesn't see cyfunction objects as functions (in pre-1.7.0 versions, inspect.isroutine() treated them as builtin functions). Is it deliberate or did it just slipped through unnoticed (since this is admitted a rare use case)? Below a simple patch that adds back the functionality without resorting to isroutine - if you agree that supporting cythonized functions is a valid use case, happy to turn it into a PR with a regression test.
--- a/pluggy/_manager.py
+++ b/pluggy/_manager.py
@@ -61,6 +61,12 @@ def _instance_dict(obj: object) -> dict[str, Any]:
return instance_dict if isinstance(instance_dict, dict) else {}
+def _is_function_or_cyfunction(obj: object) -> bool:
+ return inspect.isfunction(obj) or type(obj).__name__ in (
+ "cython_function_or_method",
+ "fused_cython_function",
+ )
+
def _static_hook_attr(
obj: object, name: str
) -> tuple[object, Callable[..., object]] | None:
@@ -93,7 +99,7 @@ def _static_hook_attr(
if value is not _ABSENT:
if isinstance(value, types.MethodType):
return value.__func__, value
- if inspect.isfunction(value):
+ if _is_function_or_cyfunction(value):
return value, value
return None
@@ -105,7 +111,7 @@ def _static_hook_attr(
return static, cast(Callable[..., object], static.__get__(owner, owner))
if isinstance(static, types.MethodType):
return static.__func__, static
- if inspect.isfunction(static):
+ if _is_function_or_cyfunction(static):
if inspect.isclass(obj) or inspect.ismodule(obj):
return static, static
return static, static.__get__(obj, type(obj))
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 200
- 平均合并
- 10 小时 4 分钟
- 30 天内合并 PR
- 13
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytest-dev/pluggy 的其他 Issue
-
Plugin registry compares plugins by equality, not identity可能已有人在做 @00200200 于 30 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
pytest-dev/pluggy#760 ·
维护者通常 1 天内回复
-
call_extra() drops arguments for partial callbacks可能已有人在做 @HocVoNgThai 于 9 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 65/100
pytest-dev/pluggy#817 ·
维护者通常 1 天内回复
-
add_hookcall_monitoring undo breaks when called out of LIFO order可能已有人在做 @AlvaroBalbin 于 7 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
pytest-dev/pluggy#815 ·
维护者通常 1 天内回复
-
call_historic() memorizes the caller's kwargs mapping, so later mutation changes what late plugins receive可能已有人在做 @RonnyPfannschmidt 于 21 天前认领。 未关闭
pytest-dev/pluggy#808 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
deprecate passing None as a plugin instance可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
pytest-dev/pluggy#790 · 1 条评论 ·
维护者通常 1 天内回复
查看 pytest-dev/pluggy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
FAIRmat-NFDI/pynxtools#861 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
NVIDIA/nsight-python#88 ·
维护者通常 1 天内回复
-
Criteria can pass when the deliverable is missing可能已有人在做 @clementtisseau 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
harveyai/harvey-labs#217 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
priority/medium roadmap/v1.1.1 stakeholder/rapr type/bug
难度 2/5 1-3 小时 新手友好度 83/100
databrickslabs/ontos#1420 ·
维护者通常 3 天内回复