Spurious `redundant-condition` when using `nonlocal`

Abierto
#5,563 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
56/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, rust
Área
backend, devtools

Línea de trabajo

Start by reproducing the warning from the linked Pyrefly sandbox and trace how the checker handles nonlocal assignments when deciding whether a condition is redundant. The issue names no source files or tests, so locate the relevant analysis code and add a regression test for the sandbox behavior. Done means the checker no longer reports if test as always false when do_thing mutates test through nonlocal.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

scoping-control-flow
Describe the Bug

In the sandbox link I posted, Pyrefly warns that if test is redundant and will always evaluate to False. However, at runtime the else branch is taken. This appears to be due to the nonlocal test statement in do_thing not being recognized as mutating test.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pVXLTsMwEPwV0xyChMDAEYkjh974gEhVmpjEIvVWfvD9zG5a7Ia2l-YUrT2z3vV49pJl8hWGffKWUthw0vujNJgYR3kuJd_TJo6wjr9N_DlyE3XtJIgcFvzDu3pZEFAcjT9Dk7lzLP9BN0xY7M9KaFbrr2ZVwApVv-boQtUl_gNLlxhyVQehzOFlJVzlopH_lVOpzzmgDpcAz4TkhgRnhpSeGlfBlI0aY9yHN62PcPKDNk731AV9gtCKH0n701rx-1M6RaL0ANpbJFvPiq2vCbbmirGDC1jXPez428jR0J2gImGYxW7EK77jNCkA35GnFK1YXdY7EwhGADyGMAO3CYNkaoegcHbpNzjHFg7jDcjBTrsdljhhknTGSTssbq7iSTbZzsbHLQZRke3qg_kF

(Only applicable for extension issues) IDE Information

No response

Lenguaje dominante
Rust
Estrellas
7.2k
Forks
578
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de facebook/pyrefly

Todos los issues de facebook/pyrefly

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.