Add a `SetVar` backed by the JS `Set` object
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- developer-experience, testing
Direzione di ricerca
Leggi packages/reflex-base/src/reflex_base/vars/sequence.py e packages/reflex-base/src/reflex_base/vars/base.py per individuare i limiti del tipo array e gli overload di LiteralVar.create. Poi esamina tests/units/test_var.py, rimuovi il cast da test_frozenset_literal_types_its_elements e aggiungi un caso di set tipizzato. Il lavoro è completato quando sia i letterali set sia quelli frozenset vengono inferiti staticamente come array con i rispettivi tipi degli elementi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 29k
- Fork
- 1.8k
- Merge medio
- 3g 7h
- PR unite (30g)
- 181
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- 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 reflex-dev/reflex
-
`rx.Model` event arguments emit `PydanticDeprecatedSince20` once per payload keyForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
reflex-dev/reflex#7634 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
`get_field_type` and `get_attribute_access_type` read `__fields__` and emit `PydanticDeprecatedSince20` on each field accessForse già presa @LaoChouPro l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
reflex-dev/reflex#7561 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
`reflex run --json` ignores SIGINT sent to its pid; under supervisord stopsignal=INT the app is orphaned and blocks the restartForse già presa @harsh21234i l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
reflex-dev/reflex#7509 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
reflex-dev/reflex#7260 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
reflex-dev/reflex#7148 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di reflex-dev/reflex
Issue simili
-
good first issue priority: low size: XS testing
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
cubrid-lab/cubrid-mcp-server#385 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue priority: low size: S testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
cubrid-lab/cubrid-cookbook-python#447 ·
I maintainer di solito rispondono entro 1 giorno
-
Python PointcloudAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ArduCAM/Arducam_tof_camera#125 ·
-
area:curator enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
CassioDalla/Scrinalia#150 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100