reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
20.42k stars 1.18k forks source link

Annotation of `rx.app.ComponentCallable` does not allow function to return `tuple[rx.Component]` #4397

Open masenf opened 5 days ago

masenf commented 5 days ago

Describe the bug

  /Users/masen/code/reflex-dev/reflex-examples/json-tree/json_tree/json_tree.py:64:14 - error: Argument of type "() -> tuple[Component]" cannot be assigned to parameter "component" of type "Component | ComponentCallable" in function "add_page"
    Type "() -> tuple[Component]" cannot be assigned to type "Component | ComponentCallable"
      "function" is incompatible with "Component"
      Type "() -> tuple[Component]" cannot be assigned to type "ComponentCallable"
        Function return type "tuple[Component]" is incompatible with type "Component"
          "tuple[Component]" is incompatible with "Component" (reportGeneralTypeIssues)

To Reproduce Having a page function (ComponentCallable) that returns a tuple of Component is just fine, the code handles... but it fails type checking.

Expected behavior Valid code should type check correctly

Specifics (please complete the following information):

linear[bot] commented 5 days ago

ENG-4129 Annotation of `rx.app.ComponentCallable` does not allow function to return `tuple[rx.Component]`