Any is excessively used as outer context for inference
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Consider this example:
from typing import Any
def foo(**kwargs: Any) -> None: ...
foo(bar=reveal_type([1])) # Revealed type is List[Any]
Such behavior causes many false negatives for plugins that provide precise type checking for various ORMs, this includes SQLAlchemy plugin, our internal plugins, and likely Django plugin.
My guess this was added so that an empty list in Any context is inferred as List[Any] instead of List[<nothing>], but I think this is counterproductive. If empty collections cause issues for plugins they can easily work around using private APIs to re-infer argument type in generated precise context (for example using has_uninhabited_component() and ctx.api.accept()). Or maybe we can provide public API for inference.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mypy で例を再現し、**kwargs: Any の呼び出しにおいて外側の Any コンテキストが reveal_type([1]) にどのような影響を与えるかを調査します。issue で言及されているプラグインの再推論 API(has_uninhabited_component() と ctx.api.accept() を含む)を確認します。完了条件は、一貫した推論動作または公開 API について合意し、それを実装することです。例と影響を受けるプラグインシナリオに対するリグレッションカバレッジも含みます。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers, devtools
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100