Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions slack_bolt/app/async_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
AsyncMessageListenerMatches,
)
from slack_bolt.oauth.async_internals import select_consistent_installation_store
from slack_bolt.util.utils import get_name_for_callable, is_coroutine_function
from slack_bolt.util.utils import get_name_for_callable, is_callable_coroutine
from slack_bolt.workflows.step.async_step import (
AsyncWorkflowStep,
AsyncWorkflowStepBuilder,
Expand Down Expand Up @@ -786,7 +786,7 @@ async def custom_error_handler(error, body, logger):
func: The function that is supposed to be executed
when getting an unhandled error in Bolt app.
"""
if not is_coroutine_function(func):
if not is_callable_coroutine(func):
name = get_name_for_callable(func)
raise BoltError(error_listener_function_must_be_coro_func(name))
self._async_listener_runner.listener_error_handler = AsyncCustomListenerErrorHandler(
Expand Down Expand Up @@ -1418,7 +1418,7 @@ def _register_listener(
value_to_return = functions[0]

for func in functions:
if not is_coroutine_function(func):
if not is_callable_coroutine(func):
name = get_name_for_callable(func)
raise BoltError(error_listener_function_must_be_coro_func(name))

Expand All @@ -1430,7 +1430,7 @@ def _register_listener(
for m in middleware or []:
if isinstance(m, AsyncMiddleware):
listener_middleware.append(m)
elif callable(m) and is_coroutine_function(m):
elif callable(m) and is_callable_coroutine(m):
listener_middleware.append(AsyncCustomMiddleware(app_name=self.name, func=m, base_logger=self._base_logger))
else:
raise ValueError(error_unexpected_listener_middleware(type(m)))
Expand Down
4 changes: 2 additions & 2 deletions slack_bolt/middleware/async_custom_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from slack_bolt.request.async_request import AsyncBoltRequest
from slack_bolt.response import BoltResponse
from .async_middleware import AsyncMiddleware
from slack_bolt.util.utils import get_name_for_callable, get_arg_names_of_callable, is_coroutine_function
from slack_bolt.util.utils import get_name_for_callable, get_arg_names_of_callable, is_callable_coroutine


class AsyncCustomMiddleware(AsyncMiddleware):
Expand All @@ -23,7 +23,7 @@ def __init__(
base_logger: Optional[Logger] = None,
):
self.app_name = app_name
if is_coroutine_function(func):
if is_callable_coroutine(func):
self.func = func
else:
raise ValueError("Async middleware function must be an async function")
Expand Down
2 changes: 1 addition & 1 deletion slack_bolt/util/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_arg_names_of_callable(func: Callable) -> List[str]:
return inspect.getfullargspec(inspect.unwrap(func)).args


def is_coroutine_function(func: Optional[Any]) -> bool:
def is_callable_coroutine(func: Optional[Any]) -> bool:
return func is not None and (
inspect.iscoroutinefunction(func) or (hasattr(func, "__call__") and inspect.iscoroutinefunction(func.__call__))
)