Latest Results
feat(vars): add SetVar for set and frozenset vars (#7642)
* feat(vars): add SetVar for set and frozenset vars
A set-typed state var or literal was an ArrayVar, so it exposed sequence
operations (indexing, map, slicing) that a set does not have, and a
frozenset was rejected by LiteralVar.create outright.
Add SetVar and LiteralSetVar for set[T] and frozenset[T]. The wire value
stays the JSON array that serialize_set already produces, which also
round-trips through event arguments, so no frontend rehydration is
needed: each operation compiles to JavaScript over that array, the way
DateTimeVar compiles over a string. contains, length, union,
intersection, difference, symmetric_difference, issubset, issuperset and
isdisjoint return SetVar or BooleanVar with the element type carried
through; to_array is the JS identity typed as a Sequence, and rx.foreach
calls it.
Remove set from ArrayVar's python types and route set and frozenset to
SetVar in figure_out_type, Var.to, var_operation and the Field and
ComputedVar overloads. The sequence operations still work on a set var
for one release with a deprecation warning pointing at to_array().
A set literal renders its elements sorted when they compare, so the
compiled output no longer depends on the process hash seed.
Closes #7623
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* fix(vars): compare set elements by value and support frozenset state
Address review findings on the SetVar change:
- Move the set operations into pySet* helpers in state.js that key
elements by value, so a set of tuples (nested arrays on the frontend)
gets Python answers from contains, union, intersection and the rest
instead of array-identity comparison.
- Register a serializer for frozenset, so a frozenset state field or
computed var is valid and reaches the frontend as an array.
- Keep an optional set optional in to_array(), so rx.foreach still
applies its null guard.
- Let the deprecated `set + set` and `array + set` fallbacks compile by
viewing set operands as arrays.
- Set the deprecation version to 0.10.1, the next release after v0.10.0.
- Check VarData propagation through a set literal in the tests.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* docs: add reflex news fragment for SetVar
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* fix(vars): keep set results free of duplicates and key strings apart
symmetric_difference with a plain array operand kept that array's
duplicates; build it as a union so the result is a set. Key strings and
objects with different prefixes in pySetKey, so a string can never share
a key with a tuple's JSON.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* docs: record the set var array-operation change as breaking
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* fix(vars): keep comparisons, contains(field) and number * set on the set var deprecation path
Comparisons (<, <=, >, >=) and contains with a field compiled on set vars
before SetVar; they now delegate to to_array() with a deprecation warning
instead of raising. NumberVar * SetVar routes to the set's deprecated
multiplication like ArrayVar does.
Also document that ==, | and & keep their generic var meaning on set vars,
reuse SET_TYPE in the var_operation overload, and drop the _element_type
pass-through.
* fix(deps): floor reflex-components-core on the reflex-base that has SetVar
reflex-base 0.10.1 was released after this branch was opened, so the
`>= 0.10.1.dev0` floor was met by a published reflex-base without
SetVar and check-min-deps failed on foreach.py. Floor at 0.10.2.dev0,
the dev release of the version after that tag, as the root package
already does.
Also admit SetVar in the NumberVar.__mul__ and __rmul__ overloads, which
the runtime path already accepts.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* fix(vars): key booleans as numbers and reflect array-left set comparisons
pySetKey now keys a boolean as the number it equals in Python, so
{1} | {True} has one element and contains(False) finds 0, as a Python
set would. ArrayVar comparisons with a SetVar on the right reflect onto
the set's deprecated comparison path, so `list_var < set_var` keeps
compiling with the deprecation warning, as `list_var + set_var` does.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* refactor(vars): move the set helpers out of state.js
The pySet* functions are not state management; they live in their own
utils/helpers/set.js module, imported like the datetime helpers.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* refactor(vars): build the set helper path from Dirs.UTILS
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* fix(vars): look up set membership with SameValueZero like the other helpers
pySetHas compared keys with ===, so a NaN element could never be found
while the other helpers use Set.has. Use the same key set lookup.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd
* perf(vars): scan for set membership without copying the array
pySetHas keeps SameValueZero (NaN matches NaN) but short-circuits over
the elements instead of building a key array and a Set per lookup.
Claude-Session: https://claude.ai/code/session_01FTaqSdpd95XTrwgxAHExRd Latest Branches
+4%
harsh21234i:fix/7617-deploy-url-playwright 0%
khaleel/databricks-sharp-screenshots 0%
claude/focused-wozniak-n9s0x3 © 2026 CodSpeed Technology