`explicit-any-use`/`unknown-from-error` errors highlight the expression but the error message references the variable

オープン
#5,710 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, rust
領域
devtools

調査の方向性

Search the Rust codebase for the diagnostic names explicit-any-use and unknown-from-error, then find where each diagnostic attaches its range and how the message gets the assigned variable name. Reproduce both snippets from the issue, or the sandbox, and compare the case where the result is not assigned. Done means the highlighted range and the message agree on whether the error is about the expression or the variable; add or update the relevant diagnostic test.

索引モデルが issue の本文から書いたものです。

説明

language-server
Describe the Bug
from typing import Any

def fn() -> Any: ...
def fn2() -> Unknown: ... # pyrefly: ignore[unknown-name]


foo = fn()
#     ^^^^ error: The type of `foo` is an explicit `Any`
foo = fn2()
#     ^^^^^ error: The type of `foo` is unknown because it comes from an error

the underlined code is the expression:

image

but the error messages refer to the variable foo.

this can be really confusing in some cases:

from typing import Any

def fn(foo: int) -> Any: ...


foo = fn(1)
#     ^^^^^ error: The type of `foo` is an explicit `Any`

here it looks like the error is talking about the function parameter called foo

idk whether the best fix is to change the range where the errors are reported or just change the error messages. i'm leaning towards the former, because the error goes away when the result is not assigned to a variable, indicating that the error is actually about the variable rather than the expression.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.lVQxDsIwDPyKpc7NgJj6DpiQUELkCATEFVABv-fspAiWqs3oxJez7-xlK_Nr0SotQh0558boqoS3-Zzlme2KGqpt6qiUuBvKdaty21yivSZtY7ba41QJaHNkZcEkiXwS8WrvkIlf_eUU4SUPCl7z8fUvwDRCZUAHjmGAhwEU5YrlZmUrvibPVXitgvQ3vvPDQjDKv-Yj2zbkN16kgDmaVOUD

(Only applicable for extension issues) IDE Information

No response

主要言語
Rust
スター
7.2k
フォーク
578
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

facebook/pyrefly のほかの issue

facebook/pyrefly の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。