fix: allow reactive variables as range steps

PE
5d ago
+130-7

rx.Var.range(0, 10, State.step) passes the input validation, then raises VarTypeError while constructing foreach/grid because step or 1 evaluates the reactive variable as a Python boolean.

Default only when the step is None, preserving the supplied variable and its state dependencies. Added a parameterized regression for public/array constructors, state/literal variables, both stride directions and an empty range. Each case constructs the real grid and compares the generated JavaScript result with Python range. Includes a reflex-base news fragment.

All Submissions

  • Followed contribution guidelines; validation scope below.
  • Checked existing PRs for this change.

Type of change

  • Bug fix

Changes To Core Features

  • Explained the change and why it is needed.
  • Added regression tests that fail on the original source.
  • Ran affected tests locally.

Zero steps keep the existing stride-of-one fallback, including state values that change to zero after construction.

Validation: 604 affected tests passed, affected Pyright has zero errors, pinned Ruff check/format pass across the repository, and the genuine changed-file pre-commit command passes.

The full unit/coverage and browser suites were not run. The earlier all-files hook run had baseline type errors; a fresh full all-files run was not repeated for this revision. The required changed-file gate passes, including its always-run type checks.