Skip to content

Commit abc8708

Browse files
authored
[ENG-5696] unwrap Var-typed annotations in @rx.memo signature (#5223)
Annotating the function arguments as `Var` might lead to more accurate type hinting, but this breaks because the annotation was being unconditionally wrapped in a Var. With this change, if the annotation is already a Var, then the inner type is used when constructing the dummy var that will be passed to the function for evaluation. Fix #5217
1 parent 6868b33 commit abc8708

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

reflex/components/component.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
no_args_event_spec,
4444
parse_args_spec,
4545
run_script,
46+
unwrap_var_annotation,
4647
)
4748
from reflex.style import Style, format_as_emotion
4849
from reflex.utils import console, format, imports, types
@@ -1936,8 +1937,8 @@ def _register_custom_component(
19361937
prop: (
19371938
Var(
19381939
"",
1939-
_var_type=annotation,
1940-
)
1940+
_var_type=unwrap_var_annotation(annotation),
1941+
).guess_type()
19411942
if not types.safe_issubclass(annotation, EventHandler)
19421943
else EventSpec(handler=EventHandler(fn=lambda: []))
19431944
)

0 commit comments

Comments
 (0)