diff --git a/shiny/render/renderer/_dispatch.py b/shiny/render/renderer/_dispatch.py index 4d1838963..8d5f63d9c 100644 --- a/shiny/render/renderer/_dispatch.py +++ b/shiny/render/renderer/_dispatch.py @@ -7,11 +7,11 @@ Callable, Literal, Protocol, - TypeGuard, TypeVar, runtime_checkable, ) +from ..._typing_extensions import TypeGuard from ...types import Jsonifiable if TYPE_CHECKING: @@ -39,7 +39,12 @@ async def __call__(self, arg: Any) -> Jsonifiable: ... def is_output_binding_request_handler(x: Any) -> TypeGuard[OutputBindingRequestHandler]: - return callable(x) and (getattr(x, "_outputBindingRequestHandler", False) == True) + if not callable(x): + return False + attr = getattr(x, "_outputBindingRequestHandler", False) + if not isinstance(attr, bool): + return False + return attr # Cast value for within `output_binding_request_handler` dispatching