Explorar o código

fix optional wrapping of static call methods in pyi (#4727)

Khaleel Al-Adhami hai 3 meses
pai
achega
15da4e17bd

+ 1 - 1
reflex/app.py

@@ -151,7 +151,7 @@ def default_backend_exception_handler(exception: Exception) -> EventSpec:
             position="top-center",
             id="backend_error",
             style={"width": "500px"},
-        )  # pyright: ignore [reportReturnType]
+        )
     else:
         error_message.insert(0, "An error occurred.")
         return window_alert("\n".join(error_message))

+ 1 - 1
reflex/components/sonner/toast.pyi

@@ -177,7 +177,7 @@ class ToastNamespace(ComponentNamespace):
     @staticmethod
     def __call__(
         message: Union[str, Var] = "", level: Optional[str] = None, **props
-    ) -> "Optional[EventSpec]":
+    ) -> "EventSpec":
         """Send a toast message.
 
         Args:

+ 1 - 0
reflex/utils/pyi_generator.py

@@ -699,6 +699,7 @@ def _generate_staticmethod_call_functiondef(
             value=_get_type_hint(
                 typing.get_type_hints(clz.__call__).get("return", None),
                 type_hint_globals,
+                is_optional=False,
             )
         ),
     )

+ 1 - 1
tests/units/test_state.py

@@ -1623,7 +1623,7 @@ async def test_state_with_invalid_yield(capsys, mock_app):
                         id="backend_error",
                         position="top-center",
                         style={"width": "500px"},
-                    )  # pyright: ignore [reportCallIssue, reportArgumentType]
+                    )
                 ],
                 token="",
             )