You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reveal_type doesn’t correctly identify the type when using rx.Var.create or NumberVar.create with a float.
You are not supposed to use NumberVar.create, use LiteralNumberVar.create or Var.create. I made a PR to improve typing of Vars created through Var.create
String formatting, like using rx.text(f"{var:.2f}"), doesn’t round floats properly.
Arithmetic operations, such as dividing a float variable by a number, don’t work as expected.
They work, they are just not typed as such. With the PR this should improve as it would report NumberVar[float] instead of Var[float] when using Var.create. However, this is mostly a typing limitation of python itself. You should be able to call .guess_type() to move from Var[float] into NumberVar[float]
Comparisons (>, <) fail outright, though equality (==) works fine.
Describe the bug
It seems like there are some serious issues with how Reflex handles
float
types. Here's what I've run into so far:reveal_type
doesn’t correctly identify the type when usingrx.Var.create
orNumberVar.create
with afloat
.rx.text(f"{var:.2f}")
, doesn’t round floats properly.>
,<
) fail outright, though equality (==
) works fine.To Reproduce:
Here’s a snippet that highlights the issues:
Here’s a snippet that highlights the issues:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
reveal_type
should return the correct type for float variables created usingrx.Var
orNumberVar
.f"{var:.2f}"
should round the float correctly.>
,<
) should also work as expected.Specifics (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: