[v1.5 regression] Repeating a type guard condition causes the guard to be lost
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend-api-design, testing
Direzione di ricerca
The report provides a Python example where repeating a TypeGuard condition with or loses the guard and causes two false positives. Start by reading the type checker’s handling of TypeGuard narrowing and boolean or expressions, then look for tests covering repeated guards. Done means the reported example preserves the narrowed type and no longer emits the false-positive diagnostics.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the Bug
Reported impact: 2 false-positive diagnostics in the attrs library
from typing import Any, TypeGuard
class C(Any):
pass
def has(cls: type) -> TypeGuard[type[C]]:
return hasattr(cls, "tag")
def f(t: type[object]) -> None:
if has(t) or has(t):
reveal_type(t)
t.tag # object has no class attribute `tag`
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
-
narrowing typechecking
Difficoltà 3/5 1-2 giorni Idoneità per principianti 69/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Cannot rename arraysAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Tutte le issue di facebook/pyrefly
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
rubys/roundhouse#1917 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
[cosmic-applet-battery] Division by zero displays NaN% when UPower reports max_brightness = 0Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
pop-os/cosmic-applets#1619 ·
I maintainer di solito rispondono entro 3 giorni
-
binding:python bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno