stubgen & pybind11: can we make them play nice(r)?
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
We're experimenting under https://github.com/pybind/pybind11/pull/4888 with a pybind11 behavior change, to generate
Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]
instead of a bare cpp_namespace::UserType.
It seems like mypy does handle outer-level Annotated, but not nested ones, e.g.
Iterator[str, Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]]
The results from stubgen (1.5.1, Google-internal toolchain) are like this:
def values(self, *args, **kwargs) -> Any: ...
Desired is:
def values(self) -> Iterator[str, Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]]: ...
Does this ring any bells?
If you need more details, please let me know. (Note though that I don't know a lot about typing and mypy. This fell into my lap as Google-internal pybind11 owner & pybind11 maintainer on github.)
A more general question: What are your thought about changing the pybind11 behavior in this way? Is there a better way?
(A clear and concise description of what the bug is.)
To Reproduce
# Ideally, a small sample program that demonstrates the problem.
# Or even better, a reproducible playground link https://mypy-play.net/ (use the "Gist" button)
Expected Behavior
Actual Behavior
Your Environment
- Mypy version used: 1.5.1, Google-internal toolchain
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
レポートでは stubgen に言及し、ネストされた Annotated の例を示していますが、リポジトリのファイルやテストはありません。まず、示されている Python 3.10 の例と stubgen 1.5.1 を使って挙動を再現し、その後、シグネチャが *args, **kwargs になる箇所を追跡してください。生成された出力が、目的のシグネチャと同じようにネストされた Iterator と Annotated の型を保持すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100