TypeIs for isinstance
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 82
説明
Apologies if I'm missing something obvious, but I checked issues and PR's and haven't seen this mentioned explicitly.
Could isinstance use TypeIs?
With multiples checks it could return an union, with one type T a TypeIs[T].
I often find myself writing one-liner helpers functions that just call isinstance, see this script for example:
https://github.com/OutSquareCapital/pyochain/blob/master/scripts/check_docstrings.py
This both add boilerplate and a performance tax due to a double function call overhead.
I'm very often using lambdas with fluent interfaces, e.g
res = (
my_iterator
.map(lambda x: ...)
.filter(lambda x: isinstance(x, int)
)
Assuming my_iterator is an Iterator[Any], it would be fantastic if it could be narrowed to Iterator[int] without having to define a separate TypeIs function.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている scripts/check_docstrings.py の例と、要求されている isinstance/TypeIs の動作から始めます。単一のチェックと複数のチェックで型をどのように絞り込むべきかを明確にし、その動作を検証するために必要な typeshed のスタブとテストを特定します。提案に明確な型付け結果と対応するカバレッジが定義されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100