Add a `SetVar` backed by the JS `Set` object
Maintainer thường phản hồi trong vòng 2 ngày
@FarhanAliRaza đang làm issue này rồi.
Từ ngày 23/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- developer-experience, testing
Hướng nghiên cứu
Đọc packages/reflex-base/src/reflex_base/vars/sequence.py và packages/reflex-base/src/reflex_base/vars/base.py để xác định giới hạn kiểu array và các overload của LiteralVar.create. Sau đó, kiểm tra tests/units/test_var.py, xóa cast khỏi test_frozenset_literal_types_its_elements và thêm một trường hợp set có kiểu. Hoàn tất khi cả literal set lẫn frozenset đều được suy luận tĩnh là array với kiểu phần tử tương ứng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 29k
- Fork
- 1.8k
- Merge trung bình
- 3 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 169
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của reflex-dev/reflex
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
reflex-dev/reflex#7260 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
reflex-dev/reflex#7148 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the defaultCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
reflex-dev/reflex#6823 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
support redis v8Đang mởfeature request
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
reflex-dev/reflex#6764 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation upstream
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
reflex-dev/reflex#6436 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của reflex-dev/reflex
Issue tương tự
-
request-theme
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
LizardByte/ThemerrDB#9575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Author Page: noshin-nawalĐang mởauthor-page correction
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
acl-org/acl-anthology#10599 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zilliztech/memsearch#818 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[FAQ] Commit ID for ProjectsCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởfaq-proposal
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
DataTalksClub/faq#503 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-freeCó thể đã có người làm @Aaqibhafeezkhan đã nhận hôm nay. Đang mởbeginner documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
BistaDinesh03/critique#164 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày