Don't report "expression contains 'Any'" if it's a `TypeOfAny.from_error`
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
Update
@A5Rocks idea about not reporting expression contains Any if it's TypeOfAny.from_error is based 100. I also realized that if it's <nothing> it would still complain about attribute access etc being incorrect.
Bug Report
The reason being that when you update an overloaded signature you can get hundreds of reported "Expression contains 'Any'" errors, when there are in reality an order of magnitude less actual errors.
from typing import overload
@overload
def foo(a: int) -> int: ...
# this overload was just removed
# @overload
# def foo(a: None) -> str ...
@overload
def foo(a: str) -> str: ...
def foo(a: object) -> object: ...
a = foo(None) # error: No overload variant of "foo" matches argument type "None"\
# error: Expression has type "Any"
reveal_type(a) # error: Expression has type "Any"\
# note: Revealed type is "Any"
print(a) # error: Expression has type "Any"
bar(a) # error: Expression has type "Any"
a + "asdf" # error: Expression has type "Any"
But If TypeOfAny.from_errors are ignored:
a = foo(None) # error: No overload variant of "foo" matches argument type "None"
reveal_type(a) # note: Revealed type is "Any"
print(a)
bar(a)
a + "asdf"
Original Title
Invocations of overloaded functions with invalid argument types shouldn't return Any it should return <nothing>
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue にある最小限のオーバーロード呼び出しの例から始め、無効なオーバーロード解決がどのように TypeOfAny.from_error を割り当て、後続の式がその型をどのように報告するかを追跡します。元のオーバーロードエラーが残り、伝播したエラー Any 値が追加の "Expression has type Any" 診断を生成しなければ完了です。issue には実行するファイルやテストの指定はありません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100