Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Tuple elements remain optional after an any() None check

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, rust

Direzione di ricerca

Start by reproducing the report with the provided Python function and confirm the returned tuple remains optional after the any() guard. Then trace Pyrefly's handling of generator expressions, any(), and type narrowing to find where the guard's effect is lost. Done means the return is accepted as tuple[int, str] while existing narrowing behavior remains intact.

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

Descrizione

Describe the Bug

After checking that no tuple element is None, Pyrefly still treats the tuple elements as optional:

def pair(
    first: int | None,
    second: str | None,
) -> tuple[int, str]:
    values = (first, second)
    if any(value is None for value in values):
        raise ValueError("missing value")

    return values

I expected Pyrefly to infer values as tuple[int, str] after the guard. Instead, it reports:

Returned type `tuple[int | None, str | None]` is not assignable to declared return type `tuple[int, str]` [bad-return]

Environment: macOS 27.0.1, Pyrefly 1.4.0, Python 3.15.2 (CLI).

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.