Add a `SetVar` backed by the JS `Set` object
Los mantenedores suelen responder en 2 días
@Huzi-06 ya está trabajando en esto.
Desde el 21/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- developer-experience, testing
Línea de trabajo
Lee packages/reflex-base/src/reflex_base/vars/sequence.py y packages/reflex-base/src/reflex_base/vars/base.py para localizar los límites del tipo array y las sobrecargas de LiteralVar.create. Después, inspecciona tests/units/test_var.py, elimina el cast de test_frozenset_literal_types_its_elements y añade un caso de set tipado. El trabajo estará terminado cuando tanto los literales de set como los de frozenset se infieran estáticamente como arrays con sus tipos de elemento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Python set values are not well supported as vars today. ArrayVar registers set among its Python types, so a set-typed state var or a set literal is treated as a plain sequence: it renders as a JS array and only array operations (length, indexing, .map, contains) are available. frozenset is not accepted at all (LiteralVar.create(frozenset(...)) raises TypeError). #7622 briefly added frozenset to ArrayVar and was reverted in #7632, because widening the array types is the wrong direction.
Proposal
Add a dedicated SetVar (and LiteralSetVar) for set[T] and frozenset[T] that compiles to a real JS Set and exposes set operations rather than array operations:
- membership:
contains/has - size:
length/size - combination:
union,intersection,difference,symmetric_difference,issubset,issuperset - conversion:
to_array(forrx.foreachand anything that wants a sequence) - the operations should return
SetVarorBoolVaras appropriate, with element typeTpreserved statically, soLiteralVar.create({"a"})is typed asSetVar[set[str]]rather than a plainVar.
Once SetVar exists, remove set from ArrayVar's Python types and make figure_out_type / _determine_value_of_array_index route set and frozenset to the new class.
Prerequisite: rehydrating Set on the frontend
State values travel to the frontend as JSON, and serialize_set turns a set into a list. There is no mechanism today to turn a JSON-encoded value back into a real Set object on the frontend, so a set-typed state var arrives as an array and a SetVar operating on it would have nothing to call .has() on.
Before SetVar can work on state vars, the frontend needs a way to rehydrate JSON values as Set objects, driven by the var's declared type (for example a per-var deserializer applied in the state delta handler, or a tagged encoding chosen on the backend). Design that first; SetVar on literals alone is not very useful.
Not in scope
Whether a set var should satisfy a Sequence[...]-typed component prop is a separate question (typehint_issubclass / _isinstance in reflex_base/utils/types.py). With SetVar the answer is probably "no, call .to_array()", but decide it separately.
Longer-horizon item; no implementation planned yet.
- Lenguaje dominante
- Python
- Estrellas
- 29k
- Forks
- 1.8k
- Merge medio
- 3 d 9 h
- PR fusionados (30 d)
- 188
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de reflex-dev/reflex
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
reflex-dev/reflex#7260 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
reflex-dev/reflex#7148 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the defaultQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
reflex-dev/reflex#6823 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
support redis v8Abiertofeature request
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
reflex-dev/reflex#6764 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 2 días
-
documentation upstream
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
reflex-dev/reflex#6436 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de reflex-dev/reflex
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
sergey-miryanov/gcmon#230 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
Los mantenedores suelen responder en 1 día
-
[BUG] Failed archive extraction deletes the dataset cachePosiblemente ocupada @dajiaohuang la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
alibaba/GraphScope#4674 ·