[v1.5 regression] Negative issubclass narrowing widens Never to object

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

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Start by reproducing the regression with the Python snippet in the issue using its sandbox link, then trace how negative issubclass checks narrow Never in Pyrefly’s type checker. The issue names no source files or tests, so locate the narrowing logic and add a regression test for the example. Done means the second issubclass call no longer reports that object is not assignable to type.

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

Descrizione

narrowing typechecking
Describe the Bug

Only adds 4 diagnostics across 2 projects, but this is a bizarre false positive:

from typing import Never

def f(x: Never) -> None:
    if issubclass(x, dict):
        return
    issubclass(x, set)  # object is not assignable to type
Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pZTBCoMwDIZfJdBDPYzl7lPsAXZxs7hd7Fjq8PH3J1WhCoJ4LWlo8_35DijTHLeEtBrrfLJmbNGS4WHLVo0XauG1ba6m4qJSApaE3Jx4JBmjUPlhNiorSlHfFLajd3TLBzT9AtIBs26A2sDieu8drBboldJHaub5evx2HHpu41O4uMGkKWt-zduEWbajaFERtD3D3Gfkfo-4V-Co2IX4Bw

(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.