Consider adding a plugin for `.__dict__`
オープン
まだ誰も着手していません。
feature
topic-plugins
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Feature
In runtime we know that __dict__ on any object contains the same fields as instance itself.
So, we can predict what is going to be inside this __dict__:
>>> class A:
... def __init__(self, x: int, y: str) -> None:
... self.x = x
... self.y = y
...
>>> A(1, 'a').__dict__
{'x': 1, 'y': 'a'}
Pitch
I think it might be very useful to infer A(1, 'a').__dict__ as TypedDict({'x': int, 'y': str}).
However:
- Performance might be an issue
- There are cases where this is not possible due to typing and runtime resons (
__getattr__,fallback_to_any, etc)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、mypyプラグインとTypedDictの推論が現在どのように扱われているかを調べ、次にオブジェクトの__dict__をそのインスタンスフィールドから推論できるかどうかを評価します。指摘されているパフォーマンス上の懸念と、__getattr__やfallback_to_anyなどの例外を考慮してください。実現可能なケースについて、定義された設計とそれを支える動作があれば完了とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100