Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add a `SetVar` backed by the JS `Set` object

オープン 初心者向け
#7,623 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@Huzi-06 がすでに取り組んでいます。

2026年10月21日 から。

  • #7625 @Huzi-06 による — オープン
  • #7642 @FarhanAliRaza による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

packages/reflex-base/src/reflex_base/vars/sequence.py と packages/reflex-base/src/reflex_base/vars/base.py を読み、array 型の境界と LiteralVar.create のオーバーロードを見つけます。次に tests/units/test_var.py を調べ、test_frozenset_literal_types_its_elements から cast を削除し、型付き set のケースを追加します。set と frozenset のリテラルがどちらも、要素の型を持つ array として静的に推論されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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 (for rx.foreach and anything that wants a sequence)
  • the operations should return SetVar or BoolVar as appropriate, with element type T preserved statically, so LiteralVar.create({"a"}) is typed as SetVar[set[str]] rather than a plain Var.

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.

主要言語
Python
スター
29k
フォーク
1.8k
平均マージ
3日 9時間
マージ済み PR(30日)
188

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

reflex-dev/reflex のほかの issue

reflex-dev/reflex の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。