Skip to content

Commit 96afa5d

Browse files
authored
Merge branch 'main' into remove-say-stream-experiement
2 parents 44bcd8c + dbe1590 commit 96afa5d

30 files changed

Lines changed: 115 additions & 81 deletions

.github/workflows/ci-build.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,19 @@ jobs:
4444
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4545
with:
4646
python-version: ${{ env.LATEST_SUPPORTED_PY }}
47-
- name: Run mypy verification
48-
run: ./scripts/run_mypy.sh
47+
- name: Install synchronous dependencies
48+
run: |
49+
pip install -U pip
50+
pip install -U .
51+
pip install -r requirements/tools.txt
52+
- name: Type check synchronous modules
53+
run: mypy --config-file pyproject.toml --exclude "async_|/adapter/"
54+
- name: Install async and adapter dependencies
55+
run: |
56+
pip install -r requirements/async.txt
57+
pip install -r requirements/adapter.txt
58+
- name: Type check all modules
59+
run: mypy --config-file pyproject.toml
4960

5061
unittest:
5162
name: Unit tests
@@ -115,7 +126,7 @@ jobs:
115126
pytest tests/scenario_tests_async/ --junitxml=reports/test_scenario_async.xml
116127
- name: Upload test results to Codecov
117128
if: ${{ !cancelled() }}
118-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
129+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
119130
with:
120131
directory: ./reports/
121132
fail_ci_if_error: true
@@ -151,7 +162,7 @@ jobs:
151162
run: |
152163
pytest --cov=./slack_bolt/ --cov-report=xml
153164
- name: Upload coverage to Codecov
154-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
165+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
155166
with:
156167
fail_ci_if_error: true
157168
report_type: coverage
@@ -168,7 +179,7 @@ jobs:
168179
if: ${{ !success() && github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch' }}
169180
steps:
170181
- name: Send notifications of failing tests
171-
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
182+
uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1
172183
with:
173184
errors: true
174185
webhook: ${{ secrets.SLACK_REGRESSION_FAILURES_WEBHOOK_URL }}

.github/workflows/dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: Collect metadata
1414
id: metadata
15-
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
15+
uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
1616
with:
1717
github-token: "${{ secrets.GITHUB_TOKEN }}"
1818
- name: Approve

.github/workflows/pypi-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252

5353
steps:
5454
- name: Retrieve dist folder
55-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
55+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5656
with:
5757
name: release-dist
5858
path: dist/
@@ -76,7 +76,7 @@ jobs:
7676

7777
steps:
7878
- name: Retrieve dist folder
79-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
79+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
8080
with:
8181
name: release-dist
8282
path: dist/

slack_bolt/app/app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
IgnoringSelfEvents,
7070
CustomMiddleware,
7171
AttachingFunctionToken,
72-
AttachingAgentKwargs,
72+
AttachingConversationKwargs,
7373
)
7474
from slack_bolt.middleware.assistant import Assistant
7575
from slack_bolt.middleware.message_listener_matches import MessageListenerMatches
@@ -133,7 +133,7 @@ def __init__(
133133
listener_executor: Optional[Executor] = None,
134134
# for AI Agents & Assistants
135135
assistant_thread_context_store: Optional[AssistantThreadContextStore] = None,
136-
attaching_agent_kwargs_enabled: bool = True,
136+
attaching_conversation_kwargs_enabled: bool = True,
137137
):
138138
"""Bolt App that provides functionalities to register middleware/listeners.
139139
@@ -354,7 +354,7 @@ def message_hello(message, say):
354354
listener_executor = ThreadPoolExecutor(max_workers=5)
355355

356356
self._assistant_thread_context_store = assistant_thread_context_store
357-
self._attaching_agent_kwargs_enabled = attaching_agent_kwargs_enabled
357+
self._attaching_conversation_kwargs_enabled = attaching_conversation_kwargs_enabled
358358

359359
self._process_before_response = process_before_response
360360
self._listener_runner = ThreadListenerRunner(
@@ -844,8 +844,8 @@ def ask_for_introduction(event, say):
844844
def __call__(*args, **kwargs):
845845
functions = self._to_listener_functions(kwargs) if kwargs else list(args)
846846
primary_matcher = builtin_matchers.event(event, base_logger=self._base_logger)
847-
if self._attaching_agent_kwargs_enabled:
848-
middleware.insert(0, AttachingAgentKwargs(self._assistant_thread_context_store))
847+
if self._attaching_conversation_kwargs_enabled:
848+
middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
849849
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
850850

851851
return __call__
@@ -903,8 +903,8 @@ def __call__(*args, **kwargs):
903903
primary_matcher = builtin_matchers.message_event(
904904
keyword=keyword, constraints=constraints, base_logger=self._base_logger
905905
)
906-
if self._attaching_agent_kwargs_enabled:
907-
middleware.insert(0, AttachingAgentKwargs(self._assistant_thread_context_store))
906+
if self._attaching_conversation_kwargs_enabled:
907+
middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
908908
middleware.insert(0, MessageListenerMatches(keyword))
909909
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
910910

slack_bolt/app/async_app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
AsyncIgnoringSelfEvents,
8787
AsyncUrlVerification,
8888
AsyncAttachingFunctionToken,
89-
AsyncAttachingAgentKwargs,
89+
AsyncAttachingConversationKwargs,
9090
)
9191
from slack_bolt.middleware.async_custom_middleware import (
9292
AsyncMiddleware,
@@ -142,7 +142,7 @@ def __init__(
142142
verification_token: Optional[str] = None,
143143
# for AI Agents & Assistants
144144
assistant_thread_context_store: Optional[AsyncAssistantThreadContextStore] = None,
145-
attaching_agent_kwargs_enabled: bool = True,
145+
attaching_conversation_kwargs_enabled: bool = True,
146146
):
147147
"""Bolt App that provides functionalities to register middleware/listeners.
148148
@@ -363,7 +363,7 @@ async def message_hello(message, say): # async function
363363
self._async_listeners: List[AsyncListener] = []
364364

365365
self._assistant_thread_context_store = assistant_thread_context_store
366-
self._attaching_agent_kwargs_enabled = attaching_agent_kwargs_enabled
366+
self._attaching_conversation_kwargs_enabled = attaching_conversation_kwargs_enabled
367367

368368
self._process_before_response = process_before_response
369369
self._async_listener_runner = AsyncioListenerRunner(
@@ -872,8 +872,8 @@ async def ask_for_introduction(event, say):
872872
def __call__(*args, **kwargs):
873873
functions = self._to_listener_functions(kwargs) if kwargs else list(args)
874874
primary_matcher = builtin_matchers.event(event, True, base_logger=self._base_logger)
875-
if self._attaching_agent_kwargs_enabled:
876-
middleware.insert(0, AsyncAttachingAgentKwargs(self._assistant_thread_context_store))
875+
if self._attaching_conversation_kwargs_enabled:
876+
middleware.insert(0, AsyncAttachingConversationKwargs(self._assistant_thread_context_store))
877877
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
878878

879879
return __call__
@@ -934,8 +934,8 @@ def __call__(*args, **kwargs):
934934
asyncio=True,
935935
base_logger=self._base_logger,
936936
)
937-
if self._attaching_agent_kwargs_enabled:
938-
middleware.insert(0, AsyncAttachingAgentKwargs(self._assistant_thread_context_store))
937+
if self._attaching_conversation_kwargs_enabled:
938+
middleware.insert(0, AsyncAttachingConversationKwargs(self._assistant_thread_context_store))
939939
middleware.insert(0, AsyncMessageListenerMatches(keyword))
940940
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
941941

slack_bolt/app/async_server.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import logging
2-
from typing import Optional
2+
from typing import Optional, TYPE_CHECKING
33

44
from aiohttp import web
55

66
from slack_bolt.adapter.aiohttp import to_bolt_request, to_aiohttp_response
77
from slack_bolt.response import BoltResponse
88
from slack_bolt.util.utils import get_boot_message
99

10+
if TYPE_CHECKING:
11+
from slack_bolt.app.async_app import AsyncApp
12+
1013

1114
class AsyncSlackAppServer:
1215
port: int
1316
path: str
1417
host: str
15-
bolt_app: "AsyncApp" # type: ignore[name-defined]
18+
bolt_app: "AsyncApp"
1619
web_app: web.Application
1720

1821
def __init__(
1922
self,
2023
port: int,
2124
path: str,
22-
app: "AsyncApp", # type: ignore[name-defined]
25+
app: "AsyncApp",
2326
host: Optional[str] = None,
2427
):
2528
"""Standalone AIOHTTP Web Server.
@@ -34,7 +37,7 @@ def __init__(
3437
self.port = port
3538
self.path = path
3639
self.host = host if host is not None else "0.0.0.0"
37-
self.bolt_app: "AsyncApp" = app # type: ignore[name-defined]
40+
self.bolt_app: "AsyncApp" = app
3841
self.web_app = web.Application()
3942
self._bolt_oauth_flow = self.bolt_app.oauth_flow
4043
if self._bolt_oauth_flow:

slack_bolt/context/async_context.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from typing import Optional, TYPE_CHECKING
22

33
from slack_sdk.web.async_client import AsyncWebClient
44

@@ -16,6 +16,9 @@
1616
from slack_bolt.context.set_title.async_set_title import AsyncSetTitle
1717
from slack_bolt.util.utils import create_copy
1818

19+
if TYPE_CHECKING:
20+
from slack_bolt.listener.asyncio_runner import AsyncioListenerRunner
21+
1922

2023
class AsyncBoltContext(BaseContext):
2124
"""Context object associated with a request from Slack."""
@@ -42,7 +45,7 @@ def to_copyable(self) -> "AsyncBoltContext":
4245

4346
# The return type is intentionally string to avoid circular imports
4447
@property
45-
def listener_runner(self) -> "AsyncioListenerRunner": # type: ignore[name-defined]
48+
def listener_runner(self) -> "AsyncioListenerRunner":
4649
"""The properly configured listener_runner that is available for middleware/listeners."""
4750
return self["listener_runner"]
4851

slack_bolt/context/context.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from typing import Optional, TYPE_CHECKING
22

33
from slack_sdk import WebClient
44

@@ -16,6 +16,9 @@
1616
from slack_bolt.context.set_title import SetTitle
1717
from slack_bolt.util.utils import create_copy
1818

19+
if TYPE_CHECKING:
20+
from slack_bolt.listener.thread_runner import ThreadListenerRunner
21+
1922

2023
class BoltContext(BaseContext):
2124
"""Context object associated with a request from Slack."""
@@ -43,7 +46,7 @@ def to_copyable(self) -> "BoltContext":
4346

4447
# The return type is intentionally string to avoid circular imports
4548
@property
46-
def listener_runner(self) -> "ThreadListenerRunner": # type: ignore[name-defined]
49+
def listener_runner(self) -> "ThreadListenerRunner":
4750
"""The properly configured listener_runner that is available for middleware/listeners."""
4851
return self["listener_runner"]
4952

slack_bolt/kwargs_injection/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def handle_buttons(args):
104104
save_thread_context: Optional[SaveThreadContext]
105105
"""`save_thread_context()` utility function for AI Agents & Assistants"""
106106
say_stream: Optional[SayStream]
107-
"""`say_stream()` utility function for AI Agents & Assistants"""
107+
"""`say_stream()` utility function for conversations, AI Agents & Assistants"""
108108
# middleware
109109
next: Callable[[], None]
110110
"""`next()` utility function, which tells the middleware chain that it can continue with the next one"""

slack_bolt/listener/async_listener_error_handler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ async def handle(
4848
)
4949
returned_response = await self.func(**kwargs)
5050
if returned_response is not None and isinstance(returned_response, BoltResponse):
51-
response.status = returned_response.status # type: ignore[union-attr]
52-
response.headers = returned_response.headers # type: ignore[union-attr]
53-
response.body = returned_response.body # type: ignore[union-attr]
51+
assert response is not None, "response must be provided when returning a BoltResponse from an error handler"
52+
response.status = returned_response.status
53+
response.headers = returned_response.headers
54+
response.body = returned_response.body
5455

5556

5657
class AsyncDefaultListenerErrorHandler(AsyncListenerErrorHandler):

0 commit comments

Comments
 (0)