Skip to content

Commit 4c1636f

Browse files
committed
fix: Replacing assert with assertion exception for when we check whether
the component is a callable
1 parent 956b75e commit 4c1636f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

reflex/app.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,19 @@ def add_page(
491491
"""
492492
# If the route is not set, get it from the callable.
493493
if route is None:
494-
assert isinstance(
495-
component, Callable
496-
), "Route must be set if component is not a callable."
497-
# Format the route.
498-
route = format.format_route(component.__name__)
494+
match component:
495+
case Callable():
496+
# Format the route.
497+
route = format.format_route(
498+
route=component.__name__,
499+
)
500+
501+
case _:
502+
error_msg: str = "Route must be set if component is not a callable."
503+
raise TypeError(
504+
error_msg,
505+
)
506+
499507
else:
500508
route = format.format_route(route, format_case=False)
501509

0 commit comments

Comments
 (0)