Skip to content

Commit aedac2c

Browse files
disc: remove the optional typing of client (#1143)
1 parent 8188956 commit aedac2c

File tree

12 files changed

+24
-24
lines changed

12 files changed

+24
-24
lines changed

slack_bolt/authorization/async_authorize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ async def __call__(
331331
return self.authorize_result_cache[token]
332332

333333
try:
334-
auth_test_api_response = await context.client.auth_test(token=token) # type: ignore[union-attr]
334+
auth_test_api_response = await context.client.auth_test(token=token)
335335
user_auth_test_response = None
336336
if user_token is not None and token != user_token:
337-
user_auth_test_response = await context.client.auth_test(token=user_token) # type: ignore[union-attr]
337+
user_auth_test_response = await context.client.auth_test(token=user_token)
338338
authorize_result = AuthorizeResult.from_auth_test_response(
339339
auth_test_response=auth_test_api_response,
340340
user_auth_test_response=user_auth_test_response,

slack_bolt/authorization/async_authorize_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
"""
3333
self.context = context
3434
self.logger = context.logger
35-
self.client = context.client # type: ignore[assignment]
35+
self.client = context.client
3636
self.enterprise_id = enterprise_id
3737
self.team_id = team_id
3838
self.user_id = user_id

slack_bolt/authorization/authorize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ def __call__(
328328
return self.authorize_result_cache[token]
329329

330330
try:
331-
auth_test_api_response = context.client.auth_test(token=token) # type: ignore[union-attr]
331+
auth_test_api_response = context.client.auth_test(token=token)
332332
user_auth_test_response = None
333333
if user_token is not None and token != user_token:
334-
user_auth_test_response = context.client.auth_test(token=user_token) # type: ignore[union-attr]
334+
user_auth_test_response = context.client.auth_test(token=user_token)
335335
authorize_result = AuthorizeResult.from_auth_test_response(
336336
auth_test_response=auth_test_api_response,
337337
user_auth_test_response=user_auth_test_response,

slack_bolt/authorization/authorize_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
"""
3333
self.context = context
3434
self.logger = context.logger
35-
self.client = context.client # type: ignore[assignment]
35+
self.client = context.client
3636
self.enterprise_id = enterprise_id
3737
self.team_id = team_id
3838
self.user_id = user_id

slack_bolt/context/async_context.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def listener_runner(self) -> "AsyncioListenerRunner": # type: ignore[name-defin
4141
return self["listener_runner"]
4242

4343
@property
44-
def client(self) -> Optional[AsyncWebClient]:
44+
def client(self) -> AsyncWebClient:
4545
"""The `AsyncWebClient` instance available for this request.
4646
4747
@app.event("app_mention")
@@ -129,8 +129,8 @@ async def handle_button_clicks(ack, respond):
129129
if "respond" not in self:
130130
self["respond"] = AsyncRespond(
131131
response_url=self.response_url,
132-
proxy=self.client.proxy, # type: ignore[union-attr]
133-
ssl=self.client.ssl, # type: ignore[union-attr]
132+
proxy=self.client.proxy,
133+
ssl=self.client.ssl,
134134
)
135135
return self["respond"]
136136

@@ -156,7 +156,7 @@ async def handle_button_clicks(context):
156156
"""
157157
if "complete" not in self:
158158
self["complete"] = AsyncComplete(
159-
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
159+
client=self.client, function_execution_id=self.function_execution_id
160160
)
161161
return self["complete"]
162162

@@ -182,6 +182,6 @@ async def handle_button_clicks(context):
182182
"""
183183
if "fail" not in self:
184184
self["fail"] = AsyncFail(
185-
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
185+
client=self.client, function_execution_id=self.function_execution_id
186186
)
187187
return self["fail"]

slack_bolt/context/context.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def listener_runner(self) -> "ThreadListenerRunner": # type: ignore[name-define
4242
return self["listener_runner"]
4343

4444
@property
45-
def client(self) -> Optional[WebClient]:
45+
def client(self) -> WebClient:
4646
"""The `WebClient` instance available for this request.
4747
4848
@app.event("app_mention")
@@ -130,8 +130,8 @@ def handle_button_clicks(ack, respond):
130130
if "respond" not in self:
131131
self["respond"] = Respond(
132132
response_url=self.response_url,
133-
proxy=self.client.proxy, # type: ignore[union-attr]
134-
ssl=self.client.ssl, # type: ignore[union-attr]
133+
proxy=self.client.proxy,
134+
ssl=self.client.ssl,
135135
)
136136
return self["respond"]
137137

@@ -157,7 +157,7 @@ def handle_button_clicks(context):
157157
"""
158158
if "complete" not in self:
159159
self["complete"] = Complete(
160-
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
160+
client=self.client, function_execution_id=self.function_execution_id
161161
)
162162
return self["complete"]
163163

@@ -183,6 +183,6 @@ def handle_button_clicks(context):
183183
"""
184184
if "fail" not in self:
185185
self["fail"] = Fail(
186-
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
186+
client=self.client, function_execution_id=self.function_execution_id
187187
)
188188
return self["fail"]

slack_bolt/middleware/attaching_function_token/async_attaching_function_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ async def async_process(
1515
next: Callable[[], Awaitable[BoltResponse]],
1616
) -> BoltResponse:
1717
if req.context.function_bot_access_token is not None:
18-
req.context.client.token = req.context.function_bot_access_token # type: ignore[union-attr]
18+
req.context.client.token = req.context.function_bot_access_token
1919

2020
return await next()

slack_bolt/middleware/attaching_function_token/attaching_function_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def process(
1515
next: Callable[[], BoltResponse],
1616
) -> BoltResponse:
1717
if req.context.function_bot_access_token is not None:
18-
req.context.client.token = req.context.function_bot_access_token # type: ignore[union-attr]
18+
req.context.client.token = req.context.function_bot_access_token
1919

2020
return next()

slack_bolt/middleware/authorization/async_multi_teams_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def async_process(
8686
req.context["token"] = token
8787
# As AsyncApp#_init_context() generates a new AsyncWebClient for this request,
8888
# it's safe to modify this instance.
89-
req.context.client.token = token # type: ignore[union-attr]
89+
req.context.client.token = token
9090
return await next()
9191
else:
9292
# This situation can arise if:

slack_bolt/middleware/authorization/async_single_team_authorization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ async def async_process(
5050

5151
try:
5252
if self.auth_test_result is None:
53-
self.auth_test_result = await req.context.client.auth_test() # type: ignore[union-attr]
53+
self.auth_test_result = await req.context.client.auth_test()
5454

5555
if self.auth_test_result:
5656
req.context.set_authorize_result(
5757
_to_authorize_result(
5858
auth_test_result=self.auth_test_result,
59-
token=req.context.client.token, # type: ignore[union-attr]
59+
token=req.context.client.token,
6060
request_user_id=req.context.user_id,
6161
)
6262
)

0 commit comments

Comments
 (0)