Skip to content

Commit

Permalink
fix: Replacing assert with assertion exception for when we check whether
Browse files Browse the repository at this point in the history
the component is a callable
  • Loading branch information
elviskahoro committed Aug 13, 2024
1 parent 483d814 commit 601cfb8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions reflex/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,19 @@ def add_page(
"""
# If the route is not set, get it from the callable.
if route is None:
assert isinstance(
component, Callable
), "Route must be set if component is not a callable."
# Format the route.
route = format.format_route(component.__name__)
match component:
case Callable():
# Format the route.
route = format.format_route(
route=component.__name__,
)

case _:
error_msg: str = "Route must be set if component is not a callable."
raise TypeError(
error_msg,
)

else:
route = format.format_route(route, format_case=False)

Expand Down

0 comments on commit 601cfb8

Please sign in to comment.