Skip to content

Commit 3403372

Browse files
committed
Add run-time type check for @event()
1 parent 0067221 commit 3403372

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

shiny/decorators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ def event(
1515
ignore_none: bool = True,
1616
ignore_init: bool = False,
1717
) -> Callable[[Callable[[], T]], Callable[[], T]]:
18+
19+
if any([not callable(arg) for arg in args]):
20+
raise TypeError(
21+
"All objects passed to event decorator must be callable.\n"
22+
+ "If you are calling `@event(f())`, try calling `@event(f)` instead."
23+
)
24+
1825
def decorator(user_fn: Callable[[], T]) -> Callable[[], T]:
1926

2027
initialized = False

0 commit comments

Comments
 (0)