Skip to content

Commit a1f1ca1

Browse files
committed
Correct type hints - thanks to pytype
1 parent 7b00fef commit a1f1ca1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

slack_bolt/middleware/authorization/internals.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,30 @@
66
from slack_bolt.request.request import BoltRequest
77
from slack_bolt.response import BoltResponse
88

9+
#
10+
# NOTE: this source file intentionally avoids having a reference to
11+
# AsyncBoltRequest, AsyncSlackResponse, and whatever Async-prefixed.
12+
#
13+
# The reason why we do so is to enable developers use sync version of Bolt
14+
# without installing aiohttp library (or any others we may use for async things)
15+
#
916

10-
def _is_url_verification(req: BoltRequest) -> bool:
17+
18+
def _is_url_verification(req: Union[BoltRequest, "AsyncBoltRequest"]) -> bool: # type: ignore
1119
return (
1220
req is not None
1321
and req.body is not None
1422
and req.body.get("type") == "url_verification"
1523
)
1624

1725

18-
def _is_ssl_check(req: BoltRequest) -> bool:
26+
def _is_ssl_check(req: Union[BoltRequest, "AsyncBoltRequest"]) -> bool: # type: ignore
1927
return (
2028
req is not None and req.body is not None and req.body.get("type") == "ssl_check"
2129
)
2230

2331

24-
def _is_uninstallation_event(req: BoltRequest) -> bool:
32+
def _is_uninstallation_event(req: Union[BoltRequest, "AsyncBoltRequest"]) -> bool: # type: ignore
2533
return (
2634
req is not None
2735
and req.body is not None
@@ -30,7 +38,7 @@ def _is_uninstallation_event(req: BoltRequest) -> bool:
3038
)
3139

3240

33-
def _is_tokens_revoked_event(req: BoltRequest) -> bool:
41+
def _is_tokens_revoked_event(req: Union[BoltRequest, "AsyncBoltRequest"]) -> bool: # type: ignore
3442
return (
3543
req is not None
3644
and req.body is not None
@@ -39,11 +47,11 @@ def _is_tokens_revoked_event(req: BoltRequest) -> bool:
3947
)
4048

4149

42-
def _is_no_auth_required(req: BoltRequest) -> bool:
50+
def _is_no_auth_required(req: Union[BoltRequest, "AsyncBoltRequest"]) -> bool: # type: ignore
4351
return _is_url_verification(req) or _is_ssl_check(req)
4452

4553

46-
def _is_no_auth_test_call_required(req: BoltRequest) -> bool:
54+
def _is_no_auth_test_call_required(req: Union[BoltRequest, "AsyncBoltRequest"]) -> bool: # type: ignore
4755
return _is_uninstallation_event(req) or _is_tokens_revoked_event(req)
4856

4957

0 commit comments

Comments
 (0)