stubgen failed to find function signature from native modules
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
Feature
I have written a native module with a hand-written docstring and signature.
The signature is available via
import inspect
import mymod
inspect.signature(mymod.MyClass.method1)
# or
help(mymod.MyClass)
# correctly prints (a,b,c)
However stubgen -p mymod generates .pyi with
class Myclass:
@classmethod
def __init__(cls, *args, **kwargs) -> None: ...
def method1(self, *args, **kwargs) -> Any: ...
filled with *args and **kwargs instead of correct signatures. (Worse, method1 is in fact staticmethod so vscode complains with this stub)
The binding is written with rust pyo3.
Since all inspect.signature, help, and IPython can read the signature, I think the problem is in stubgen.
I don't know the internals of stubgen, but would it help to use inspect.signature when other methods in generate_stub_for_c_module fail?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず stubgen's generate_stub_for_c_module パスを読み、ネイティブモジュールの例で、現在のシグネチャ検出フォールバックと inspect.signature を比較します。stubgen がドキュメント化されたパラメーターシグネチャを出力し、汎用的な *args と **kwargs を使用するのではなく、staticmethod などのメソッド種別を保持すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python, rust
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100