Skip to content

Commit

Permalink
Update _dispatch.py
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Mar 21, 2024
1 parent 3247b8a commit 8e8282e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shiny/render/renderer/_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
Callable,
Literal,
Protocol,
TypeGuard,
TypeVar,
runtime_checkable,
)

from ..._typing_extensions import TypeGuard
from ...types import Jsonifiable

if TYPE_CHECKING:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8e8282e

Please sign in to comment.