Skip to content

Commit 99cccd1

Browse files
committed
fix: codegen async
1 parent cba64c1 commit 99cccd1

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

scripts/codegen.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import argparse
2+
import sys
33

44
parser = argparse.ArgumentParser()
55
parser.add_argument("-p", "--path", help="Path to the project source code.", type=str)
@@ -47,6 +47,23 @@
4747
async_source,
4848
)
4949
async_source = re.sub(r"= WebClient\(", "= AsyncWebClient(", async_source)
50+
async_source = re.sub(
51+
"from slack_sdk.web.chat_stream import ChatStream",
52+
"from slack_sdk.web.async_chat_stream import AsyncChatStream",
53+
async_source,
54+
)
55+
async_source = re.sub(r"ChatStream:", "AsyncChatStream:", async_source)
56+
async_source = re.sub(r"ChatStream\(", "AsyncChatStream(", async_source)
57+
async_source = re.sub(
58+
r" streamer.append\(",
59+
" await streamer.append(",
60+
async_source,
61+
)
62+
async_source = re.sub(
63+
r" streamer.stop\(",
64+
" await streamer.stop(",
65+
async_source,
66+
)
5067
async_source = re.sub(
5168
r" self.files_getUploadURLExternal\(",
5269
" await self.files_getUploadURLExternal(",

slack_sdk/web/async_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import slack_sdk.errors as e
2020
from slack_sdk.models.views import View
21-
from slack_sdk.web.chat_stream import ChatStream
21+
from slack_sdk.web.async_chat_stream import AsyncChatStream
2222

2323
from ..models.attachments import Attachment
2424
from ..models.blocks import Block
@@ -2916,7 +2916,7 @@ async def chat_stream(
29162916
unfurl_links: Optional[bool] = None,
29172917
unfurl_media: Optional[bool] = None,
29182918
**kwargs,
2919-
) -> ChatStream:
2919+
) -> AsyncChatStream:
29202920
"""Stream markdown text into a conversation.
29212921
29222922
This method provides an easy way to stream markdown text using the following endpoints:
@@ -2945,12 +2945,12 @@ async def chat_stream(
29452945
recipient_team_id="T0123456789",
29462946
recipient_user_id="U0123456789",
29472947
)
2948-
streamer.append(markdown_text="**hello wo")
2949-
streamer.append(markdown_text="rld!**")
2950-
streamer.stop()
2948+
await streamer.append(markdown_text="**hello wo")
2949+
await streamer.append(markdown_text="rld!**")
2950+
await streamer.stop()
29512951
```
29522952
"""
2953-
return ChatStream(
2953+
return AsyncChatStream(
29542954
self,
29552955
logger=self._logger,
29562956
channel=channel,

0 commit comments

Comments
 (0)