Incorrect narrowing after `TypeIs[type[...]]` check
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 53/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- devtools, testing-qa
Direzione di ricerca
Start by reproducing the narrowing behavior in the linked Pyrefly sandbox, then trace how custom TypeIs predicates narrow both branches in the Rust type checker. Compare the TypeIs[type[bytes]] example with the built-in issubclass example and find the relevant narrowing tests. Done means the else branch retains the appropriate type instead of becoming Never, with regression coverage for the example.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the Bug
narrowing with a custom -> TypeIs[type[Foo]] incorrectly narrows the else branch to Never:
from typing import TypeIs, reveal_type
def is_bytes(obj: object, /) -> TypeIs[type[bytes]]:
return isinstance(obj, type) and issubclass(obj, bytes)
def check(cls: type, /) -> None:
if is_bytes(cls):
reveal_type(cls) # type[bytes]
else:
reveal_type(cls) # Never
def check2(cls: type, /) -> None:
if issubclass(cls, bytes):
reveal_type(cls) # type[bytes]
else:
reveal_type(cls) # type[Any]
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à 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
-
fuzz-crash review-followup
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 Mezza giornata Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
aws/aws-emulator#610 ·