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
While writing tests for get_attribute_access_type I discovered that Vars with Optional type annotation and a default value of None do not pass Component prop validation. But the values can always change to None at runtime.
fromtypingimportOptionalimportreflexasrxclassState(rx.State):
no_default: strstr_default: str="bla"opt_no_default: Optional[str]
opt_str_default: Optional[str] ="bla"opt_none_default: Optional[str] =Nonedefindex() ->rx.Component:
returnrx.vstack(
# works finerx.input(value=State.no_default),
# works finerx.input(value=State.str_default),
# TypeError: Invalid var passed for prop value, expected type typing.Union[str, int, bool], got value opt_no_default of type typing.Optional[str].# rx.input(value=State.opt_no_default),# works finerx.input(value=State.opt_str_default),
# TypeError: Invalid var passed for prop value, expected type typing.Union[str, int, bool], got value opt_none_default of type typing.Optional[str].# rx.input(value=State.opt_none_default),
)
app=rx.App()
app.add_page(index)
Expected behavior
more consistent behavior with None/undefined defaults
Specifics (please complete the following information):
Python Version: 3.12.3
Reflex Version: main branch
OS: arch
Browser (Optional): ---
The text was updated successfully, but these errors were encountered:
Describe the bug
While writing tests for get_attribute_access_type I discovered that Vars with
Optional
type annotation and a default value ofNone
do not pass Component prop validation. But the values can always change toNone
at runtime.To Reproduce
https://github.com/benedikt-bartscher/test-optional
Expected behavior
more consistent behavior with None/undefined defaults
Specifics (please complete the following information):
The text was updated successfully, but these errors were encountered: