Need plugin hooks for functions/methods
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
For some frameworks like pytest it would be useful to have a plugin that works with functions.
Currently mypy has decorator hook for classes.
Some ideas for possible hooks:
- update function namespace to inject some names
- modify function signature
- generate function signature (types)
For example pytest has the following fixture
from pathlib import Path
@pytest.fixture
def db_path(tmp_path: Path) -> Path:
return tmp_path / 'test.db'
The fixture is used by name:
def test_a(db_path) -> None:
....
db_path argument here is a calucated the result of db_path() fixture call.
It is bound by parameter name which is the same as the fixture name.
Adding a type to db_path argument is tedious, especially if a fixture returns some complex type like Callable[[str, int], Awaitable[web.Response]].
Technically all needed information can be extracted from fixture definition if the definition is type annotated.
A plugin for pytest would be awesome but as @ilevkivskyi said mypy needs a new hook to support it.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、クラス向けの mypy の既存の decorator hook と、issue で説明されている plugin API の概念を確認します。pytest スタイルの fixture について、関数名前空間への注入、シグネチャの変更、生成されるシグネチャがどのように機能すべきかを判断し、その後、fixture パラメーターが推論された戻り値の型を受け取ることを示すテストを定義します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100