Skip to content

Commit e629000

Browse files
authored
pyi_generator: handle Callable[[], None] annotation for LambdaVar (#5282)
* pyi_generator: handle `Callable[[], None]` annotation for LambdaVar If the annotation is a list, process it recursively and return a list. * Include annotated assignments in namespace classes This allows a namespace to also include classes and type aliases
1 parent 60df907 commit e629000

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

reflex/utils/pyi_generator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ def _get_type_hint(
221221
if ev.__name__ == "Var"
222222
else value
223223
)
224+
elif isinstance(value, list):
225+
res = [
226+
_get_type_hint(arg, type_hint_globals, rx_types.is_optional(arg))
227+
for arg in value
228+
]
229+
return f"[{', '.join(res)}]"
224230
else:
225231
res = value.__name__
226232
if is_optional and not res.startswith("Optional") and not res.endswith("| None"):
@@ -1029,7 +1035,7 @@ def visit_AnnAssign(self, node: ast.AnnAssign) -> ast.AnnAssign | None:
10291035
return node
10301036
if isinstance(node.target, ast.Name) and node.target.id.startswith("_"):
10311037
return None
1032-
if self.current_class in self.classes:
1038+
if self._current_class_is_component():
10331039
# Remove annotated assignments in Component classes (props)
10341040
return None
10351041
# Blank out assignments in type stubs.

0 commit comments

Comments
 (0)