Skip to content

Commit

Permalink
disc: remove the optional typing of client (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBergamin authored Sep 2, 2024
1 parent 8188956 commit aedac2c
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions slack_bolt/authorization/async_authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ async def __call__(
return self.authorize_result_cache[token]

try:
auth_test_api_response = await context.client.auth_test(token=token) # type: ignore[union-attr]
auth_test_api_response = await context.client.auth_test(token=token)
user_auth_test_response = None
if user_token is not None and token != user_token:
user_auth_test_response = await context.client.auth_test(token=user_token) # type: ignore[union-attr]
user_auth_test_response = await context.client.auth_test(token=user_token)
authorize_result = AuthorizeResult.from_auth_test_response(
auth_test_response=auth_test_api_response,
user_auth_test_response=user_auth_test_response,
Expand Down
2 changes: 1 addition & 1 deletion slack_bolt/authorization/async_authorize_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
"""
self.context = context
self.logger = context.logger
self.client = context.client # type: ignore[assignment]
self.client = context.client
self.enterprise_id = enterprise_id
self.team_id = team_id
self.user_id = user_id
4 changes: 2 additions & 2 deletions slack_bolt/authorization/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ def __call__(
return self.authorize_result_cache[token]

try:
auth_test_api_response = context.client.auth_test(token=token) # type: ignore[union-attr]
auth_test_api_response = context.client.auth_test(token=token)
user_auth_test_response = None
if user_token is not None and token != user_token:
user_auth_test_response = context.client.auth_test(token=user_token) # type: ignore[union-attr]
user_auth_test_response = context.client.auth_test(token=user_token)
authorize_result = AuthorizeResult.from_auth_test_response(
auth_test_response=auth_test_api_response,
user_auth_test_response=user_auth_test_response,
Expand Down
2 changes: 1 addition & 1 deletion slack_bolt/authorization/authorize_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
"""
self.context = context
self.logger = context.logger
self.client = context.client # type: ignore[assignment]
self.client = context.client
self.enterprise_id = enterprise_id
self.team_id = team_id
self.user_id = user_id
10 changes: 5 additions & 5 deletions slack_bolt/context/async_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def listener_runner(self) -> "AsyncioListenerRunner": # type: ignore[name-defin
return self["listener_runner"]

@property
def client(self) -> Optional[AsyncWebClient]:
def client(self) -> AsyncWebClient:
"""The `AsyncWebClient` instance available for this request.
@app.event("app_mention")
Expand Down Expand Up @@ -129,8 +129,8 @@ async def handle_button_clicks(ack, respond):
if "respond" not in self:
self["respond"] = AsyncRespond(
response_url=self.response_url,
proxy=self.client.proxy, # type: ignore[union-attr]
ssl=self.client.ssl, # type: ignore[union-attr]
proxy=self.client.proxy,
ssl=self.client.ssl,
)
return self["respond"]

Expand All @@ -156,7 +156,7 @@ async def handle_button_clicks(context):
"""
if "complete" not in self:
self["complete"] = AsyncComplete(
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
client=self.client, function_execution_id=self.function_execution_id
)
return self["complete"]

Expand All @@ -182,6 +182,6 @@ async def handle_button_clicks(context):
"""
if "fail" not in self:
self["fail"] = AsyncFail(
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
client=self.client, function_execution_id=self.function_execution_id
)
return self["fail"]
10 changes: 5 additions & 5 deletions slack_bolt/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def listener_runner(self) -> "ThreadListenerRunner": # type: ignore[name-define
return self["listener_runner"]

@property
def client(self) -> Optional[WebClient]:
def client(self) -> WebClient:
"""The `WebClient` instance available for this request.
@app.event("app_mention")
Expand Down Expand Up @@ -130,8 +130,8 @@ def handle_button_clicks(ack, respond):
if "respond" not in self:
self["respond"] = Respond(
response_url=self.response_url,
proxy=self.client.proxy, # type: ignore[union-attr]
ssl=self.client.ssl, # type: ignore[union-attr]
proxy=self.client.proxy,
ssl=self.client.ssl,
)
return self["respond"]

Expand All @@ -157,7 +157,7 @@ def handle_button_clicks(context):
"""
if "complete" not in self:
self["complete"] = Complete(
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
client=self.client, function_execution_id=self.function_execution_id
)
return self["complete"]

Expand All @@ -183,6 +183,6 @@ def handle_button_clicks(context):
"""
if "fail" not in self:
self["fail"] = Fail(
client=self.client, function_execution_id=self.function_execution_id # type: ignore[arg-type]
client=self.client, function_execution_id=self.function_execution_id
)
return self["fail"]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ async def async_process(
next: Callable[[], Awaitable[BoltResponse]],
) -> BoltResponse:
if req.context.function_bot_access_token is not None:
req.context.client.token = req.context.function_bot_access_token # type: ignore[union-attr]
req.context.client.token = req.context.function_bot_access_token

return await next()
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def process(
next: Callable[[], BoltResponse],
) -> BoltResponse:
if req.context.function_bot_access_token is not None:
req.context.client.token = req.context.function_bot_access_token # type: ignore[union-attr]
req.context.client.token = req.context.function_bot_access_token

return next()
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def async_process(
req.context["token"] = token
# As AsyncApp#_init_context() generates a new AsyncWebClient for this request,
# it's safe to modify this instance.
req.context.client.token = token # type: ignore[union-attr]
req.context.client.token = token
return await next()
else:
# This situation can arise if:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ async def async_process(

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

if self.auth_test_result:
req.context.set_authorize_result(
_to_authorize_result(
auth_test_result=self.auth_test_result,
token=req.context.client.token, # type: ignore[union-attr]
token=req.context.client.token,
request_user_id=req.context.user_id,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def process(
req.context["token"] = token
# As App#_init_context() generates a new WebClient for this request,
# it's safe to modify this instance.
req.context.client.token = token # type: ignore[union-attr]
req.context.client.token = token
return next()
else:
# This situation can arise if:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def process(

try:
if not self.auth_test_result:
self.auth_test_result = req.context.client.auth_test() # type: ignore[union-attr]
self.auth_test_result = req.context.client.auth_test()

if self.auth_test_result:
req.context.set_authorize_result(
_to_authorize_result(
auth_test_result=self.auth_test_result,
token=req.context.client.token, # type: ignore[union-attr]
token=req.context.client.token,
request_user_id=req.context.user_id,
)
)
Expand Down

0 comments on commit aedac2c

Please sign in to comment.