Plugin api named_type() is ambiguous and inconsistent and broken
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
The plugin API defines two different interfaces (TypeAnalyzerPluginInterface and SemanticAnalyzerPluginInterface) that each define a method named_type(). These look almost identical, but looks are deceptive.
First, the specified signatures differ subtly:
- The second argument to SemanticAnalyzerPluginInterface.named_type() is optional, while for TypeAnalyzerPluginInterface.named_type() is is mandatory.
- Also the first argument name differs (qualified_name vs. plain name).
Second, the implementations differ:
- The semantic analyzer (in semanal.py) starts the lookup in the local namespace, then globals, then builtins.
- The type checker (in checker.py) has two different strategies: if there's no dot in the name, it starts in globals, then builtins; but if there's a dot, it starts in the table of modules (i.e. the current scope doesn't enter into it).
Third, the type checker's named_type() implementation doesn't actually take a list of type arguments at all -- it's a method with only one argument, the name to look up. It always fills in all type parameters with Any. (It looks like the method we want here is named_generic_type().)
Fourth, apparently mypy's own type checking doesn't catch the discrepancy between the implemented spec (only a name) and the interface spec (name + args).
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、TypeAnalyzerPluginInterface.named_type() と SemanticAnalyzerPluginInterface.named_type() を、semanal.py と checker.py の実装と比較します。named_generic_type() と型チェックの設定を調べ、シグネチャの不一致が検出されない理由を理解します。プラグインのインターフェースと実装で一貫した合意済みの API が定義され、不一致が型チェックまたはテストによってカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100