`explicit-any-use`/`unknown-from-error` errors highlight the expression but the error message references the variable
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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:
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
(Only applicable for extension issues) IDE Information
No response
- Lingua principale
- Rust
- Stelle
- 7.2k
- Fork
- 578
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di facebook/pyrefly
-
pytorch tensor-shapes typechecking
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue typechecking
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
cargo b warning: unused dependency `zstd`Forse già presa @Narendersingh007 l’ha presa 4 giorni fa. Apertagood first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
pydantic
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di facebook/pyrefly
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
eventflux-io/eventflux#203 ·
I maintainer di solito rispondono entro 1 giorno
-
bug ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
userFRM/egui-charts#4068 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
trezor/trezor-firmware#8357 ·
I maintainer di solito rispondono entro 2 giorni
-
fuzz-crash review-followup
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno