-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix type propagation in ToStringOperation #3895
Conversation
Co-authored-by: Masen Furer <m_github@0x26.net>
@benedikt-bartscher I haven't had a look into our |
I see no good reason to not propagate the specialized type for ints as well |
When looking into if issubclass(fixed_type, bool):
return self.to(BooleanVar, self._var_type)
if issubclass(fixed_type, (int, float)):
return self.to(NumberVar, self._var_type)
if issubclass(fixed_type, dict):
return self.to(ObjectVar, self._var_type)
if issubclass(fixed_type, (list, tuple, set)):
return self.to(ArrayVar, self._var_type)
if issubclass(fixed_type, str):
return self.to(StringVar) # var_type not propagated here !!!
if issubclass(fixed_type, Base):
return self.to(ObjectVar, self._var_type)
return self |
When emitting a state update, restore `_self_mutable` to the value it had previously so that `yield` in the middle of `async with self` does not result in an immutable StateProxy. Fix reflex-dev#3869
If a component in the markdown component_map contains children components, use `_get_all_imports` to recursively enumerate them. Fix reflex-dev#3880
I am not (yet) deep into the new var system, but that sounds like a better approach, and it seems like you already migrated to it? |
Mmh, locally the integration-app-harness tests are passing. |
you need to merge main, fixed in #3902 |
Co-authored-by: Masen Furer <m_github@0x26.net>
Thanks @masenf and @benedikt-bartscher. Now I can sleep peacefully 😃 |
what is ToStringOperation? i got this datatype in my app state all the time!
|
What is a bit hard in the beginning is to understand that there are two types of code. Runtime is everything that is carried out in/via event handlers on state. class MyState(rx.State):
my_property: rx.Field[str] = rx.field("123")
@rx.event
def calculate_int_like_crazy(self):
print(int(self.my_property)) # At runtime type(self.my_property) == str
@rx.page
def index():
return rx.box(MyState.my_property) # At compiletime type(MyState.my_property) == ToStringOperation All stuff that is evaluated during compile time is baked into the JS that renders the frontend. So sometimes it is better to do some calculations there. Have a look at |
Type of change
closes #3890