Przeglądaj źródła

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
Masen Furer 2 tygodni temu
rodzic
commit
e629000f84
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      reflex/utils/pyi_generator.py

+ 7 - 1
reflex/utils/pyi_generator.py

@@ -221,6 +221,12 @@ def _get_type_hint(
             if ev.__name__ == "Var"
             else value
         )
+    elif isinstance(value, list):
+        res = [
+            _get_type_hint(arg, type_hint_globals, rx_types.is_optional(arg))
+            for arg in value
+        ]
+        return f"[{', '.join(res)}]"
     else:
         res = value.__name__
     if is_optional and not res.startswith("Optional") and not res.endswith("| None"):
@@ -1029,7 +1035,7 @@ class StubGenerator(ast.NodeTransformer):
             return node
         if isinstance(node.target, ast.Name) and node.target.id.startswith("_"):
             return None
-        if self.current_class in self.classes:
+        if self._current_class_is_component():
             # Remove annotated assignments in Component classes (props)
             return None
         # Blank out assignments in type stubs.