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 天內回覆