Skip to content

Commit bfe6216

Browse files
authored
Upgrade pytype to the latest (#496)
1 parent 81d0e7a commit bfe6216

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

.github/workflows/ci-build.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ jobs:
7272
run: |
7373
python_version=`python -V`
7474
if [ ${python_version:7:3} == "3.8" ]; then
75-
pip install -e ".[async]"
76-
pip install -e ".[adapter]"
77-
# TODO: upgrade pytype
78-
pip install "pytype==2021.9.27" && pytype slack_bolt/
75+
./scripts/run_pytype.sh
7976
fi
8077
- name: Run all tests for codecov (3.9 only)
8178
run: |

scripts/run_pytype.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
script_dir=$(dirname $0)
55
cd ${script_dir}/.. && \
6+
pip install -e ".[async]" && \
67
pip install -e ".[adapter]" && \
7-
# TODO: upgrade pytype
8-
pip install "pytype==2021.9.27" && \
8+
pip install "pytype==2021.10.11" && \
99
pytype slack_bolt/

slack_bolt/app/app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def message_hello(message, say):
179179
listener_executor: Custom executor to run background tasks. If absent, the default `ThreadPoolExecutor` will
180180
be used.
181181
"""
182-
signing_secret = signing_secret or os.environ.get("SLACK_SIGNING_SECRET")
182+
signing_secret = signing_secret or os.environ.get("SLACK_SIGNING_SECRET", "")
183183
token = token or os.environ.get("SLACK_BOT_TOKEN")
184184

185185
self._name: str = name or inspect.stack()[1].filename.split(os.path.sep)[-1]
@@ -304,7 +304,7 @@ def message_hello(message, say):
304304
# Middleware Initialization
305305
# --------------------------------------
306306

307-
self._middleware_list: List[Union[Callable, Middleware]] = []
307+
self._middleware_list: List[Middleware] = []
308308
self._listeners: List[Listener] = []
309309

310310
if listener_executor is None:
@@ -469,7 +469,7 @@ def dispatch(self, req: BoltRequest) -> BoltResponse:
469469
starting_time = time.time()
470470
self._init_context(req)
471471

472-
resp: BoltResponse = BoltResponse(status=200, body="")
472+
resp: Optional[BoltResponse] = BoltResponse(status=200, body="")
473473
middleware_state = {"next_called": False}
474474

475475
def middleware_next():
@@ -607,7 +607,8 @@ def middleware_func(logger, body, next):
607607
if len(args) > 0:
608608
middleware_or_callable = args[0]
609609
if isinstance(middleware_or_callable, Middleware):
610-
self._middleware_list.append(middleware_or_callable)
610+
middleware: Middleware = middleware_or_callable
611+
self._middleware_list.append(middleware)
611612
elif isinstance(middleware_or_callable, Callable):
612613
self._middleware_list.append(
613614
CustomMiddleware(app_name=self.name, func=middleware_or_callable)

slack_bolt/app/async_app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def message_hello(message, say): # async function
183183
oauth_flow: Instantiated `slack_bolt.oauth.AsyncOAuthFlow`. This is always prioritized over oauth_settings.
184184
verification_token: Deprecated verification mechanism. This can used only for ssl_check requests.
185185
"""
186-
signing_secret = signing_secret or os.environ.get("SLACK_SIGNING_SECRET")
186+
signing_secret = signing_secret or os.environ.get("SLACK_SIGNING_SECRET", "")
187187
token = token or os.environ.get("SLACK_BOT_TOKEN")
188188

189189
self._name: str = name or inspect.stack()[1].filename.split(os.path.sep)[-1]
@@ -327,7 +327,7 @@ async def message_hello(message, say): # async function
327327
# Middleware Initialization
328328
# --------------------------------------
329329

330-
self._async_middleware_list: List[Union[Callable, AsyncMiddleware]] = []
330+
self._async_middleware_list: List[AsyncMiddleware] = []
331331
self._async_listeners: List[AsyncListener] = []
332332

333333
self._process_before_response = process_before_response
@@ -506,7 +506,7 @@ async def async_dispatch(self, req: AsyncBoltRequest) -> BoltResponse:
506506
starting_time = time.time()
507507
self._init_context(req)
508508

509-
resp: BoltResponse = BoltResponse(status=200, body="")
509+
resp: Optional[BoltResponse] = BoltResponse(status=200, body="")
510510
middleware_state = {"next_called": False}
511511

512512
async def async_middleware_next():
@@ -642,7 +642,8 @@ async def middleware_func(logger, body, next):
642642
if len(args) > 0:
643643
middleware_or_callable = args[0]
644644
if isinstance(middleware_or_callable, AsyncMiddleware):
645-
self._async_middleware_list.append(middleware_or_callable)
645+
middleware: AsyncMiddleware = middleware_or_callable
646+
self._async_middleware_list.append(middleware)
646647
elif isinstance(middleware_or_callable, Callable):
647648
self._async_middleware_list.append(
648649
AsyncCustomMiddleware(

slack_bolt/app/async_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__( # type:ignore
2929
"""
3030
self.port = port
3131
self.path = path
32-
self.bolt_app: "AsyncApp" = app
32+
self.bolt_app: "AsyncApp" = app # type: ignore
3333
self.web_app = web.Application()
3434
self._bolt_oauth_flow = self.bolt_app.oauth_flow
3535
if self._bolt_oauth_flow:

0 commit comments

Comments
 (0)