-
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
fallback to ObjectVar in guess_type #3911
fallback to ObjectVar in guess_type #3911
Conversation
Merge remote-tracking branch 'upstream/main' into guess-type-fallback
Merge remote-tracking branch 'upstream/main' into guess-type-fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adhami3310 what do you think of this one
I'm a bit concerned here on the general case, for example, a union of an int and str might be an ObjectVar now. It feels, impure, but maybe practicality trumps correctness. To engage more, why were you creating so many ObjectVar? Can we find a better adjustment to the API to allow this behavior be simpler as an alternative? |
Because we often write serializers for existing objects and just want to use them in the frontend without creating an additional rx.Base "proxy class". |
ImmutableVar.__getattr__
does not allow attribute access andguess_type
does not guessObjectVar
for arbitrary objects. In our codebases, this results in a lotvar.to(ObjectVar)
sthis pr currently just adds a fallback. Maybe we can instead check if there is a serializer which serializes to dict?