Skip to content

Commit 42b6c4d

Browse files
Improve conssistancy in naming
1 parent 6a7f0f7 commit 42b6c4d

8 files changed

Lines changed: 74 additions & 70 deletions

File tree

slack_bolt/context/say_stream/async_say_stream.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99

1010
class AsyncSayStream:
1111
client: AsyncWebClient
12-
channel_id: Optional[str]
12+
channel: Optional[str]
1313
thread_ts: Optional[str]
14-
team_id: Optional[str]
15-
user_id: Optional[str]
14+
recipient_team_id: Optional[str]
15+
recipient_user_id: Optional[str]
1616

1717
def __init__(
1818
self,
1919
*,
2020
client: AsyncWebClient,
21-
channel_id: Optional[str] = None,
21+
channel: Optional[str] = None,
2222
thread_ts: Optional[str] = None,
23-
team_id: Optional[str] = None,
24-
user_id: Optional[str] = None,
23+
recipient_team_id: Optional[str] = None,
24+
recipient_user_id: Optional[str] = None,
2525
):
2626
self.client = client
27-
self.channel_id = channel_id
27+
self.channel = channel
2828
self.thread_ts = thread_ts
29-
self.team_id = team_id
30-
self.user_id = user_id
29+
self.recipient_team_id = recipient_team_id
30+
self.recipient_user_id = recipient_user_id
3131

3232
async def __call__(
3333
self,
@@ -44,7 +44,7 @@ async def __call__(
4444
stacklevel=2,
4545
)
4646

47-
channel = channel or self.channel_id
47+
channel = channel or self.channel
4848
thread_ts = thread_ts or self.thread_ts
4949
if channel is None:
5050
raise ValueError("say_stream without channel here is unsupported")
@@ -54,7 +54,7 @@ async def __call__(
5454
return await self.client.chat_stream(
5555
channel=channel,
5656
thread_ts=thread_ts,
57-
recipient_team_id=recipient_team_id or self.team_id,
58-
recipient_user_id=recipient_user_id or self.user_id,
57+
recipient_team_id=recipient_team_id or self.recipient_team_id,
58+
recipient_user_id=recipient_user_id or self.recipient_user_id,
5959
**kwargs,
6060
)

slack_bolt/context/say_stream/say_stream.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99

1010
class SayStream:
1111
client: WebClient
12-
channel_id: Optional[str]
12+
channel: Optional[str]
1313
thread_ts: Optional[str]
14-
team_id: Optional[str]
15-
user_id: Optional[str]
14+
recipient_team_id: Optional[str]
15+
recipient_user_id: Optional[str]
1616

1717
def __init__(
1818
self,
1919
*,
2020
client: WebClient,
21-
channel_id: Optional[str] = None,
21+
channel: Optional[str] = None,
2222
thread_ts: Optional[str] = None,
23-
team_id: Optional[str] = None,
24-
user_id: Optional[str] = None,
23+
recipient_team_id: Optional[str] = None,
24+
recipient_user_id: Optional[str] = None,
2525
):
2626
self.client = client
27-
self.channel_id = channel_id
27+
self.channel = channel
2828
self.thread_ts = thread_ts
29-
self.team_id = team_id
30-
self.user_id = user_id
29+
self.recipient_team_id = recipient_team_id
30+
self.recipient_user_id = recipient_user_id
3131

3232
def __call__(
3333
self,
@@ -44,7 +44,7 @@ def __call__(
4444
stacklevel=2,
4545
)
4646

47-
channel = channel or self.channel_id
47+
channel = channel or self.channel
4848
thread_ts = thread_ts or self.thread_ts
4949
if channel is None:
5050
raise ValueError("say_stream without channel here is unsupported")
@@ -54,7 +54,7 @@ def __call__(
5454
return self.client.chat_stream(
5555
channel=channel,
5656
thread_ts=thread_ts,
57-
recipient_team_id=recipient_team_id or self.team_id,
58-
recipient_user_id=recipient_user_id or self.user_id,
57+
recipient_team_id=recipient_team_id or self.recipient_team_id,
58+
recipient_user_id=recipient_user_id or self.recipient_user_id,
5959
**kwargs,
6060
)

slack_bolt/middleware/attaching_agent_kwargs/async_attaching_agent_kwargs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ async def async_process(
4343
if req.context.channel_id and thread_ts:
4444
req.context["say_stream"] = AsyncSayStream(
4545
client=req.context.client,
46-
channel_id=req.context.channel_id,
46+
channel=req.context.channel_id,
4747
thread_ts=thread_ts,
48-
team_id=req.context.team_id,
49-
user_id=req.context.user_id,
48+
recipient_team_id=req.context.team_id,
49+
recipient_user_id=req.context.user_id,
5050
)
5151
return await next()

slack_bolt/middleware/attaching_agent_kwargs/attaching_agent_kwargs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def process(self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], Bo
3737
if req.context.channel_id and thread_ts:
3838
req.context["say_stream"] = SayStream(
3939
client=req.context.client,
40-
channel_id=req.context.channel_id,
40+
channel=req.context.channel_id,
4141
thread_ts=thread_ts,
42-
team_id=req.context.team_id,
43-
user_id=req.context.user_id,
42+
recipient_team_id=req.context.team_id,
43+
recipient_user_id=req.context.user_id,
4444
)
4545
return next()

tests/scenario_tests/test_events_say_stream.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ def test_say_stream_injected_for_app_mention(self):
5454
def handle_mention(say_stream: SayStream, context: BoltContext):
5555
assert say_stream is not None
5656
assert isinstance(say_stream, SayStream)
57-
assert say_stream.channel_id == "C111"
57+
assert say_stream == context.say_stream
58+
assert say_stream.channel == "C111"
5859
assert say_stream.thread_ts == "1595926230.009600"
59-
assert say_stream.team_id == context.team_id
60-
assert say_stream.user_id == context.user_id
60+
assert say_stream.recipient_team_id == context.team_id
61+
assert say_stream.recipient_user_id == context.user_id
6162
called["value"] = True
6263

6364
request = BoltRequest(body=app_mention_event_body, mode="socket_mode")
@@ -73,10 +74,11 @@ def test_say_stream_injected_for_threaded_message(self):
7374
def handle_message(say_stream: SayStream, context: BoltContext):
7475
assert say_stream is not None
7576
assert isinstance(say_stream, SayStream)
76-
assert say_stream.channel_id == "D111"
77+
assert say_stream == context.say_stream
78+
assert say_stream.channel == "D111"
7779
assert say_stream.thread_ts == "1726133698.626339"
78-
assert say_stream.team_id == context.team_id
79-
assert say_stream.user_id == context.user_id
80+
assert say_stream.recipient_team_id == context.team_id
81+
assert say_stream.recipient_user_id == context.user_id
8082
called["value"] = True
8183

8284
request = BoltRequest(body=threaded_user_message_event_body, mode="socket_mode")
@@ -92,7 +94,7 @@ def test_say_stream_in_user_message(self):
9294
def handle_user_message(say_stream: SayStream):
9395
assert say_stream is not None
9496
assert isinstance(say_stream, SayStream)
95-
assert say_stream.channel_id == "C111"
97+
assert say_stream.channel == "C111"
9698
assert say_stream.thread_ts == "1610261659.001400"
9799
called["value"] = True
98100

@@ -109,7 +111,7 @@ def test_say_stream_in_bot_message(self):
109111
def handle_bot_message(say_stream: SayStream):
110112
assert say_stream is not None
111113
assert isinstance(say_stream, SayStream)
112-
assert say_stream.channel_id == "C111"
114+
assert say_stream.channel == "C111"
113115
assert say_stream.thread_ts == "1610261539.000900"
114116
called["value"] = True
115117

@@ -142,7 +144,7 @@ def test_say_stream_in_assistant_thread_started(self):
142144
def start_thread(say_stream: SayStream):
143145
assert say_stream is not None
144146
assert isinstance(say_stream, SayStream)
145-
assert say_stream.channel_id == "D111"
147+
assert say_stream.channel == "D111"
146148
assert say_stream.thread_ts == "1726133698.626339"
147149
called["value"] = True
148150

@@ -162,7 +164,7 @@ def test_say_stream_in_assistant_user_message(self):
162164
def handle_user_message(say_stream: SayStream):
163165
assert say_stream is not None
164166
assert isinstance(say_stream, SayStream)
165-
assert say_stream.channel_id == "D111"
167+
assert say_stream.channel == "D111"
166168
assert say_stream.thread_ts == "1726133698.626339"
167169
called["value"] = True
168170

tests/scenario_tests_async/test_events_say_stream.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ async def test_say_stream_injected_for_app_mention(self):
5858
async def handle_mention(say_stream: AsyncSayStream, context: AsyncBoltContext):
5959
assert say_stream is not None
6060
assert isinstance(say_stream, AsyncSayStream)
61-
assert say_stream.channel_id == "C111"
61+
assert say_stream == context.say_stream
62+
assert say_stream.channel == "C111"
6263
assert say_stream.thread_ts == "1595926230.009600"
63-
assert say_stream.team_id == context.team_id
64-
assert say_stream.user_id == context.user_id
64+
assert say_stream.recipient_team_id == context.team_id
65+
assert say_stream.recipient_user_id == context.user_id
6566
called["value"] = True
6667

6768
request = AsyncBoltRequest(body=app_mention_event_body, mode="socket_mode")
@@ -78,10 +79,11 @@ async def test_say_stream_injected_for_threaded_message(self):
7879
async def handle_message(say_stream: AsyncSayStream, context: AsyncBoltContext):
7980
assert say_stream is not None
8081
assert isinstance(say_stream, AsyncSayStream)
81-
assert say_stream.channel_id == "D111"
82+
assert say_stream == context.say_stream
83+
assert say_stream.channel == "D111"
8284
assert say_stream.thread_ts == "1726133698.626339"
83-
assert say_stream.team_id == context.team_id
84-
assert say_stream.user_id == context.user_id
85+
assert say_stream.recipient_team_id == context.team_id
86+
assert say_stream.recipient_user_id == context.user_id
8587
called["value"] = True
8688

8789
request = AsyncBoltRequest(body=threaded_user_message_event_body, mode="socket_mode")
@@ -98,7 +100,7 @@ async def test_say_stream_in_user_message(self):
98100
async def handle_user_message(say_stream: AsyncSayStream):
99101
assert say_stream is not None
100102
assert isinstance(say_stream, AsyncSayStream)
101-
assert say_stream.channel_id == "C111"
103+
assert say_stream.channel == "C111"
102104
assert say_stream.thread_ts == "1610261659.001400"
103105
called["value"] = True
104106

@@ -116,7 +118,7 @@ async def test_say_stream_in_bot_message(self):
116118
async def handle_user_message(say_stream: AsyncSayStream):
117119
assert say_stream is not None
118120
assert isinstance(say_stream, AsyncSayStream)
119-
assert say_stream.channel_id == "C111"
121+
assert say_stream.channel == "C111"
120122
assert say_stream.thread_ts == "1610261539.000900"
121123
called["value"] = True
122124

@@ -151,7 +153,7 @@ async def test_say_stream_in_assistant_thread_started(self):
151153
async def start_thread(say_stream: AsyncSayStream, context: AsyncBoltContext):
152154
assert say_stream is not None
153155
assert isinstance(say_stream, AsyncSayStream)
154-
assert say_stream.channel_id == "D111"
156+
assert say_stream.channel == "D111"
155157
assert say_stream.thread_ts == "1726133698.626339"
156158
called["value"] = True
157159

@@ -172,7 +174,7 @@ async def test_say_stream_in_assistant_user_message(self):
172174
async def handle_user_message(say_stream: AsyncSayStream, context: AsyncBoltContext):
173175
assert say_stream is not None
174176
assert isinstance(say_stream, AsyncSayStream)
175-
assert say_stream.channel_id == "D111"
177+
assert say_stream.channel == "D111"
176178
assert say_stream.thread_ts == "1726133698.626339"
177179
called["value"] = True
178180

tests/slack_bolt/context/test_say_stream.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ def teardown_method(self):
1717
cleanup_mock_web_api_server(self)
1818

1919
def test_missing_channel_raises(self):
20-
say_stream = SayStream(client=self.web_client, channel_id=None, thread_ts="111.222")
20+
say_stream = SayStream(client=self.web_client, channel=None, thread_ts="111.222")
2121
with pytest.warns(ExperimentalWarning):
2222
with pytest.raises(ValueError, match="channel"):
2323
say_stream()
2424

2525
def test_missing_thread_ts_raises(self):
26-
say_stream = SayStream(client=self.web_client, channel_id="C111", thread_ts=None)
26+
say_stream = SayStream(client=self.web_client, channel="C111", thread_ts=None)
2727
with pytest.warns(ExperimentalWarning):
2828
with pytest.raises(ValueError, match="thread_ts"):
2929
say_stream()
3030

3131
def test_default_params(self):
3232
say_stream = SayStream(
3333
client=self.web_client,
34-
channel_id="C111",
34+
channel="C111",
3535
thread_ts="111.222",
36-
team_id="T111",
37-
user_id="U111",
36+
recipient_team_id="T111",
37+
recipient_user_id="U111",
3838
)
3939
stream = say_stream()
4040

@@ -49,10 +49,10 @@ def test_default_params(self):
4949
def test_parameter_overrides(self):
5050
say_stream = SayStream(
5151
client=self.web_client,
52-
channel_id="C111",
52+
channel="C111",
5353
thread_ts="111.222",
54-
team_id="T111",
55-
user_id="U111",
54+
recipient_team_id="T111",
55+
recipient_user_id="U111",
5656
)
5757
stream = say_stream(channel="C222", thread_ts="333.444", recipient_team_id="T222", recipient_user_id="U222")
5858

@@ -67,7 +67,7 @@ def test_parameter_overrides(self):
6767
def test_buffer_size_passthrough(self):
6868
say_stream = SayStream(
6969
client=self.web_client,
70-
channel_id="C111",
70+
channel="C111",
7171
thread_ts="111.222",
7272
)
7373
stream = say_stream(buffer_size=100)
@@ -77,7 +77,7 @@ def test_buffer_size_passthrough(self):
7777
def test_experimental_warning(self):
7878
say_stream = SayStream(
7979
client=self.web_client,
80-
channel_id="C111",
80+
channel="C111",
8181
thread_ts="111.222",
8282
)
8383
with pytest.warns(ExperimentalWarning, match="say_stream is experimental"):

tests/slack_bolt_async/context/test_async_say_stream.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ def setup_teardown(self):
2626

2727
@pytest.mark.asyncio
2828
async def test_missing_channel_raises(self):
29-
say_stream = AsyncSayStream(client=self.web_client, channel_id=None, thread_ts="111.222")
29+
say_stream = AsyncSayStream(client=self.web_client, channel=None, thread_ts="111.222")
3030
with pytest.warns(ExperimentalWarning):
3131
with pytest.raises(ValueError, match="channel"):
3232
await say_stream()
3333

3434
@pytest.mark.asyncio
3535
async def test_missing_thread_ts_raises(self):
36-
say_stream = AsyncSayStream(client=self.web_client, channel_id="C111", thread_ts=None)
36+
say_stream = AsyncSayStream(client=self.web_client, channel="C111", thread_ts=None)
3737
with pytest.warns(ExperimentalWarning):
3838
with pytest.raises(ValueError, match="thread_ts"):
3939
await say_stream()
@@ -42,10 +42,10 @@ async def test_missing_thread_ts_raises(self):
4242
async def test_default_params(self):
4343
say_stream = AsyncSayStream(
4444
client=self.web_client,
45-
channel_id="C111",
45+
channel="C111",
4646
thread_ts="111.222",
47-
team_id="T111",
48-
user_id="U111",
47+
recipient_team_id="T111",
48+
recipient_user_id="U111",
4949
)
5050
stream = await say_stream()
5151
assert stream._stream_args == {
@@ -60,10 +60,10 @@ async def test_default_params(self):
6060
async def test_parameter_overrides(self):
6161
say_stream = AsyncSayStream(
6262
client=self.web_client,
63-
channel_id="C111",
63+
channel="C111",
6464
thread_ts="111.222",
65-
team_id="T111",
66-
user_id="U111",
65+
recipient_team_id="T111",
66+
recipient_user_id="U111",
6767
)
6868
stream = await say_stream(channel="C222", thread_ts="333.444", recipient_team_id="T222", recipient_user_id="U222")
6969

@@ -79,7 +79,7 @@ async def test_parameter_overrides(self):
7979
async def test_buffer_size_passthrough(self):
8080
say_stream = AsyncSayStream(
8181
client=self.web_client,
82-
channel_id="C111",
82+
channel="C111",
8383
thread_ts="111.222",
8484
)
8585
stream = await say_stream(buffer_size=100)
@@ -90,7 +90,7 @@ async def test_buffer_size_passthrough(self):
9090
async def test_experimental_warning(self):
9191
say_stream = AsyncSayStream(
9292
client=self.web_client,
93-
channel_id="C111",
93+
channel="C111",
9494
thread_ts="111.222",
9595
)
9696
with pytest.warns(ExperimentalWarning, match="say_stream is experimental"):

0 commit comments

Comments
 (0)