Skip to content

Commit 6f4854b

Browse files
chore: naming of is_coroutine_function (#1134)
1 parent a9ead73 commit 6f4854b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

slack_bolt/app/async_app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
AsyncMessageListenerMatches,
2626
)
2727
from slack_bolt.oauth.async_internals import select_consistent_installation_store
28-
from slack_bolt.util.utils import get_name_for_callable, is_coroutine_function
28+
from slack_bolt.util.utils import get_name_for_callable, is_callable_coroutine
2929
from slack_bolt.workflows.step.async_step import (
3030
AsyncWorkflowStep,
3131
AsyncWorkflowStepBuilder,
@@ -786,7 +786,7 @@ async def custom_error_handler(error, body, logger):
786786
func: The function that is supposed to be executed
787787
when getting an unhandled error in Bolt app.
788788
"""
789-
if not is_coroutine_function(func):
789+
if not is_callable_coroutine(func):
790790
name = get_name_for_callable(func)
791791
raise BoltError(error_listener_function_must_be_coro_func(name))
792792
self._async_listener_runner.listener_error_handler = AsyncCustomListenerErrorHandler(
@@ -1418,7 +1418,7 @@ def _register_listener(
14181418
value_to_return = functions[0]
14191419

14201420
for func in functions:
1421-
if not is_coroutine_function(func):
1421+
if not is_callable_coroutine(func):
14221422
name = get_name_for_callable(func)
14231423
raise BoltError(error_listener_function_must_be_coro_func(name))
14241424

@@ -1430,7 +1430,7 @@ def _register_listener(
14301430
for m in middleware or []:
14311431
if isinstance(m, AsyncMiddleware):
14321432
listener_middleware.append(m)
1433-
elif callable(m) and is_coroutine_function(m):
1433+
elif callable(m) and is_callable_coroutine(m):
14341434
listener_middleware.append(AsyncCustomMiddleware(app_name=self.name, func=m, base_logger=self._base_logger))
14351435
else:
14361436
raise ValueError(error_unexpected_listener_middleware(type(m)))

slack_bolt/middleware/async_custom_middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from slack_bolt.request.async_request import AsyncBoltRequest
77
from slack_bolt.response import BoltResponse
88
from .async_middleware import AsyncMiddleware
9-
from slack_bolt.util.utils import get_name_for_callable, get_arg_names_of_callable, is_coroutine_function
9+
from slack_bolt.util.utils import get_name_for_callable, get_arg_names_of_callable, is_callable_coroutine
1010

1111

1212
class AsyncCustomMiddleware(AsyncMiddleware):
@@ -23,7 +23,7 @@ def __init__(
2323
base_logger: Optional[Logger] = None,
2424
):
2525
self.app_name = app_name
26-
if is_coroutine_function(func):
26+
if is_callable_coroutine(func):
2727
self.func = func
2828
else:
2929
raise ValueError("Async middleware function must be an async function")

slack_bolt/util/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def get_arg_names_of_callable(func: Callable) -> List[str]:
9090
return inspect.getfullargspec(inspect.unwrap(func)).args
9191

9292

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

0 commit comments

Comments
 (0)