Suppression comments in inactive code are reported as unused

Aperta
#5,680 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, rust

Direzione di ricerca

Start by reproducing the report in the Pyrefly sandbox using the provided configuration and Python example. Then trace how inactive branches and # type: ignore comments are analyzed; the payload names no source files or tests, so locate the relevant test entry point. Done when the reported suppression is recognized as used and a regression test covers the example.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

has-open-pr quansight
Describe the Bug
# Pyrefly sandbox configuration.
# See https://pyrefly.org/en/docs/configuration/ for available configuration options.
python-version = "3.12"
[errors]
unimported-directive = 'ignore'
not-required-key-access = 'warn'
no-any-return = 'error'
unused-type-ignore = 'error'
import sys

def via_else() -> int:
    if sys.version_info < (3,13):
        return 0
    else:
        x = 1
        return "x"  # type: ignore
ERROR sandbox.py:8:21-35: Unused `# type: ignore` comment [[unused-type-ignore](https://pyrefly.org/en/docs/error-kinds/#unused-type-ignore)]

I don't think the "unused # type: ignore" diagnostic is right? The return 'x' is incompatible with -> int so the # type: ignore isn't in fact unused?

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pVRLDoIwEL3KBBa4ECphZzyEByAxjSKyaY2lBBfe3TdtjVbQDdt2ZjLvM-9XZMaXx4IOnTywAbyoYPptPFQVATXWOGva0apal9WMmzazThqBrZzU1slYJ0QpRzfuIBDE0L-IT2nvHyhgQORAsdYi2LBTUasUmdbQpe-vZivEq13fWtEocdJHI6IOQewxOcjOxWU8jrQzisHYJYpnHk_2T--M5XYVuVR3FDle8O6G48Mqa9DEBOV-3ufvRPmIt8cT

(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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di facebook/pyrefly

Tutte le issue di facebook/pyrefly

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.