bug inferring signatures from docstrings in stubgenc
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
When generating stubs from c modules, stubgen uses mypy.stubdoc to parse signatures from docstrings, if they are present, however, this does not work if the function takes no arguments
To Reproduce
Function with args:
>>> from mypy.stubdoc import infer_sig_from_docstring
>>> infer_sig_from_docstring('func(x) -> int', 'func')
[FunctionSig(name='func', args=[ArgSig(name='x', type=None, default=False)], ret_type='int')]
Function without args:
>>>: infer_sig_from_docstring('func() -> int', 'func')
[] # <--- no signature!!!!
The fact that no signatures are returned means that the stubs that are generated look like this:
def func(*args, **kwargs) -> Any
...
But given that we have a docstring with a valid signature, the stubs should look like this:
def func() -> int
...
This seems like a bug. I'll make a PR to fix this when I have some time.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mypy.stubdoc.infer_sig_from_docstring から始めて、issue の 2 つの例を再現し、その後、stubgen が返されたシグネチャをどのように使うかを追跡します。func() -> int のような引数なしの docstring がシグネチャを生成し、stubgen が *args/**kwargs フォールバックではなく、対応する型付き関数スタブを生成すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100