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
{{ message }}
Repository navigation
[REF-3160] [VarOps] It is way too easy to pass incorrect kwargs to rx.Var._replace #3531
Describe the bug
This _replace func accepts arbitrary kwargs, pulls out the ones it recognizes, and passes those off to BaseVar constructor. Meanwhile, any remainin unrecognized kwargs are just jettisoned without any errors.
This means if I pass _merge_var_data instead of merge_var_data, it silently does the wrong thing.
changed the title [-][VarOps] It is way too easy to pass incorrect kwargs to `rx.Var._replace`[/-][+][REF-3160] [VarOps] It is way too easy to pass incorrect kwargs to `rx.Var._replace`[/+]on Jun 20, 2024
I noticed in vars.py that the _replace function typically takes class variables of BaseVars, Vars, or ComputedVar as kwargs. I propose a solution to create a custom decorator for verifying kwargs.
In this decorator, we can either pass the class and it will automatically consider the class variables, or we can pass a set of expected kwargs, if the values passes is outside the set it will throw and TypeError. This decorator might be useful at multiple places too .
Activity
[-][VarOps] It is way too easy to pass incorrect kwargs to `rx.Var._replace`[/-][+][REF-3160] [VarOps] It is way too easy to pass incorrect kwargs to `rx.Var._replace`[/+]Manas1820 commentedon Jun 22, 2024
Hey @masenf
I noticed in vars.py that the _replace function typically takes class variables of BaseVars, Vars, or ComputedVar as kwargs. I propose a solution to create a custom decorator for verifying kwargs.
In this decorator, we can either pass the class and it will automatically consider the class variables, or we can pass a set of expected kwargs, if the values passes is outside the set it will throw and TypeError. This decorator might be useful at multiple places too .
Let me know your thoughts on this !