Selaa lähdekoodia

raise error on private events (#5152)

Khaleel Al-Adhami 1 kuukausi sitten
vanhempi
säilyke
351ac2ac58
1 muutettua tiedostoa jossa 2 lisäystä ja 0 poistoa
  1. 2 0
      reflex/event.py

+ 2 - 0
reflex/event.py

@@ -2064,6 +2064,8 @@ class EventNamespace:
                         "Background task must be async function or generator."
                     )
                 setattr(func, BACKGROUND_TASK_MARKER, True)
+            if getattr(func, "__name__", "").startswith("_"):
+                raise ValueError("Event handlers cannot be private.")
             return func  # pyright: ignore [reportReturnType]
 
         if func is not None: