Option to remove unsupported annotations from `numpy.ndarray` and `List` in stubgen
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Feature
Command-line arguments for stubgen that when enabled will remove unsupported annotations from numpy.ndarray and List
like numpy.ndarray[numpy.float32[3,1]] and List[float[3]] which pybind11 outputs.
FYI: This feature has been implemented for numpy.ndarray in pybind11-stubgen.
Pitch
The stubs generated from extensions made with pybind11 using mypy.stubs are invalid when Eigen types or std::array are used in the interface.
As an example, this output from stubgen,
def as_numpy(self) -> numpy.ndarray[numpy.float32[3,1]]: ...
will give the following errors when used together with Mypy:
error: Bad number of arguments for type alias, expected: 0, given: 2
error: "ndarray" expects 2 type arguments, but 1 given
error: Invalid type: try using Literal[2] instead?
error: Invalid type: try using Literal[1] instead?
And this
def split(axis_aligned_bounding_box: AxisAlignedBoundingBox, max_extents: List[float[3]]) -> List[AxisAlignedBoundingBox]: ...
will give these errors:
error: "float" expects no type arguments, but 1 given
error: Invalid type: try using Literal[3] instead?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
stubgen のコマンドラインエントリポイントから開始し、numpy.ndarray[...] や List[...] などのアノテーションがどのように出力されるかを追跡します。サポートされていないアノテーションを削除するオプションを追加し、生成されたスタブで説明されている mypy エラーが発生しなくなることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- numpy, python
- 領域
- cli, devtools, tooling
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100