From aacb319094667f1d865a291c491911fda7af573b Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Sat, 23 Apr 2022 20:02:19 +0900 Subject: [PATCH 1/5] Enable Flake8 in the CI builds --- .flake8 | 3 +++ .github/workflows/flake8.yml | 23 +++++++++++++++++++ examples/django/myslackapp/urls.py | 2 +- examples/django/simple_app/models.py | 2 +- examples/getting_started/app.py | 1 + examples/google_cloud_functions/main.py | 1 + .../workflow_steps/async_steps_from_apps.py | 6 ++--- .../async_steps_from_apps_decorator.py | 2 +- .../async_steps_from_apps_primitive.py | 2 +- examples/workflow_steps/steps_from_apps.py | 2 +- .../steps_from_apps_decorator.py | 2 +- .../steps_from_apps_primitive.py | 2 +- scripts/run_flake8.sh | 7 ++++++ slack_bolt/__init__.py | 4 ++-- slack_bolt/adapter/aws_lambda/__init__.py | 2 +- slack_bolt/adapter/bottle/__init__.py | 2 +- slack_bolt/adapter/cherrypy/__init__.py | 2 +- slack_bolt/adapter/django/__init__.py | 2 +- slack_bolt/adapter/django/handler.py | 4 ++-- slack_bolt/adapter/falcon/__init__.py | 2 +- slack_bolt/adapter/flask/__init__.py | 2 +- slack_bolt/adapter/pyramid/__init__.py | 2 +- slack_bolt/adapter/sanic/__init__.py | 2 +- slack_bolt/adapter/socket_mode/__init__.py | 4 ++-- slack_bolt/adapter/starlette/__init__.py | 2 +- slack_bolt/adapter/tornado/__init__.py | 2 +- slack_bolt/app/__init__.py | 2 +- slack_bolt/async_app.py | 2 +- slack_bolt/authorization/__init__.py | 2 +- slack_bolt/context/__init__.py | 2 +- slack_bolt/context/ack/__init__.py | 2 +- slack_bolt/context/ack/internals.py | 2 +- slack_bolt/context/respond/__init__.py | 2 +- slack_bolt/context/say/__init__.py | 2 +- slack_bolt/kwargs_injection/__init__.py | 4 ++-- slack_bolt/kwargs_injection/utils.py | 2 +- slack_bolt/lazy_listener/async_runner.py | 2 +- slack_bolt/listener/builtins.py | 2 -- slack_bolt/listener_matcher/builtins.py | 3 +-- slack_bolt/logger/messages.py | 5 +++- slack_bolt/middleware/__init__.py | 17 ++++++++------ slack_bolt/middleware/async_builtins.py | 16 ++++++------- .../middleware/authorization/__init__.py | 6 ++--- slack_bolt/middleware/ssl_check/ssl_check.py | 2 +- slack_bolt/oauth/internals.py | 2 +- slack_bolt/request/__init__.py | 2 +- slack_bolt/response/__init__.py | 2 +- slack_bolt/workflows/step/__init__.py | 12 +++++----- slack_bolt/workflows/step/async_step.py | 6 ++--- slack_bolt/workflows/step/step.py | 6 ++--- 50 files changed, 115 insertions(+), 77 deletions(-) create mode 100644 .flake8 create mode 100644 .github/workflows/flake8.yml create mode 100755 scripts/run_flake8.sh diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..9960c210e --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 125 +ignore = F841,F821,W503,E402 diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml new file mode 100644 index 000000000..f13674516 --- /dev/null +++ b/.github/workflows/flake8.yml @@ -0,0 +1,23 @@ +name: Run pytype validation + +on: + push: + branches: [ main ] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + matrix: + python-version: ['3.9'] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Run pytype verification + run: | + ./scripts/run_pytype.sh diff --git a/examples/django/myslackapp/urls.py b/examples/django/myslackapp/urls.py index 754cee871..f3d5c7268 100644 --- a/examples/django/myslackapp/urls.py +++ b/examples/django/myslackapp/urls.py @@ -13,7 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.contrib import admin +from django.contrib import admin # noqa: F401 from django.urls import path # Set this flag to False if you want to enable oauth_app instead diff --git a/examples/django/simple_app/models.py b/examples/django/simple_app/models.py index 71a836239..82c4e7854 100644 --- a/examples/django/simple_app/models.py +++ b/examples/django/simple_app/models.py @@ -1,3 +1,3 @@ -from django.db import models +from django.db import models # noqa: F401 # Create your models here. diff --git a/examples/getting_started/app.py b/examples/getting_started/app.py index 96944a594..22cdf5f31 100644 --- a/examples/getting_started/app.py +++ b/examples/getting_started/app.py @@ -7,6 +7,7 @@ signing_secret=os.environ.get("SLACK_SIGNING_SECRET"), ) + # Listens to incoming messages that contain "hello" # To learn available listener method arguments, # visit https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html diff --git a/examples/google_cloud_functions/main.py b/examples/google_cloud_functions/main.py index 633efb67b..c9f911a90 100644 --- a/examples/google_cloud_functions/main.py +++ b/examples/google_cloud_functions/main.py @@ -26,6 +26,7 @@ def event_test(body, say, logger): handler = SlackRequestHandler(app) + # Cloud Function def hello_bolt_app(request): """HTTP Cloud Function. diff --git a/examples/workflow_steps/async_steps_from_apps.py b/examples/workflow_steps/async_steps_from_apps.py index 06307be7d..e8831a113 100644 --- a/examples/workflow_steps/async_steps_from_apps.py +++ b/examples/workflow_steps/async_steps_from_apps.py @@ -28,7 +28,7 @@ async def edit(ack: AsyncAck, step: dict, configure: AsyncConfigure): "block_id": "intro-section", "text": { "type": "plain_text", - "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", + "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", # noqa: E501 }, }, { @@ -155,8 +155,8 @@ async def execute( "blocks": blocks, }, ) - except: - await fail(error={"message": "Something wrong!"}) + except Exception as e: + await fail(error={"message": f"Something wrong! (error: {e})"}) app.step( diff --git a/examples/workflow_steps/async_steps_from_apps_decorator.py b/examples/workflow_steps/async_steps_from_apps_decorator.py index 7c88a39a0..64e45a881 100644 --- a/examples/workflow_steps/async_steps_from_apps_decorator.py +++ b/examples/workflow_steps/async_steps_from_apps_decorator.py @@ -33,7 +33,7 @@ async def edit(ack: AsyncAck, step: dict, configure: AsyncConfigure): "block_id": "intro-section", "text": { "type": "plain_text", - "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", + "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", # noqa: E501 }, }, { diff --git a/examples/workflow_steps/async_steps_from_apps_primitive.py b/examples/workflow_steps/async_steps_from_apps_primitive.py index a343d0005..8d585be5a 100644 --- a/examples/workflow_steps/async_steps_from_apps_primitive.py +++ b/examples/workflow_steps/async_steps_from_apps_primitive.py @@ -27,7 +27,7 @@ async def edit(body: dict, ack: AsyncAck, client: AsyncWebClient): "block_id": "intro-section", "text": { "type": "plain_text", - "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", + "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", # noqa: E501 }, }, { diff --git a/examples/workflow_steps/steps_from_apps.py b/examples/workflow_steps/steps_from_apps.py index 147aa5d05..43e47c38d 100644 --- a/examples/workflow_steps/steps_from_apps.py +++ b/examples/workflow_steps/steps_from_apps.py @@ -31,7 +31,7 @@ def edit(ack: Ack, step, configure: Configure): "block_id": "intro-section", "text": { "type": "plain_text", - "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", + "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", # noqa: E501 }, }, { diff --git a/examples/workflow_steps/steps_from_apps_decorator.py b/examples/workflow_steps/steps_from_apps_decorator.py index 6ccccd975..0a8802731 100644 --- a/examples/workflow_steps/steps_from_apps_decorator.py +++ b/examples/workflow_steps/steps_from_apps_decorator.py @@ -35,7 +35,7 @@ def edit(ack: Ack, step, configure: Configure): "block_id": "intro-section", "text": { "type": "plain_text", - "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", + "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", # noqa: E501 }, }, { diff --git a/examples/workflow_steps/steps_from_apps_primitive.py b/examples/workflow_steps/steps_from_apps_primitive.py index 96ad0c97b..175bcde98 100644 --- a/examples/workflow_steps/steps_from_apps_primitive.py +++ b/examples/workflow_steps/steps_from_apps_primitive.py @@ -29,7 +29,7 @@ def edit(body: dict, ack: Ack, client: WebClient): "block_id": "intro-section", "text": { "type": "plain_text", - "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", + "text": "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.", # noqa: E501 }, }, { diff --git a/scripts/run_flake8.sh b/scripts/run_flake8.sh new file mode 100755 index 000000000..59cd510e6 --- /dev/null +++ b/scripts/run_flake8.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# ./scripts/run_pytype.sh + +script_dir=$(dirname $0) +cd ${script_dir}/.. && \ + pip install "flake8==4.0.1" && \ + flake8 slack_bolt/ && flake8 examples/ diff --git a/slack_bolt/__init__.py b/slack_bolt/__init__.py index 20563758d..4050d83a9 100644 --- a/slack_bolt/__init__.py +++ b/slack_bolt/__init__.py @@ -1,10 +1,10 @@ """ -A Python framework to build Slack apps in a flash with the latest platform features. Read the [getting started guide](https://slack.dev/bolt-python/tutorial/getting-started) and look at our [code examples](https://github.com/slackapi/bolt-python/tree/main/examples) to learn how to build apps using Bolt. +A Python framework to build Slack apps in a flash with the latest platform features.Read the [getting started guide](https://slack.dev/bolt-python/tutorial/getting-started) and look at our [code examples](https://github.com/slackapi/bolt-python/tree/main/examples) to learn how to build apps using Bolt. * Website: https://slack.dev/bolt-python/ * GitHub repository: https://github.com/slackapi/bolt-python * The class representing a Bolt app: `slack_bolt.app.app` -""" +""" # noqa: E501 # Don't add async module imports here from .app import App # noqa from .context import BoltContext # noqa diff --git a/slack_bolt/adapter/aws_lambda/__init__.py b/slack_bolt/adapter/aws_lambda/__init__.py index f08c97a5f..df8fd9d79 100644 --- a/slack_bolt/adapter/aws_lambda/__init__.py +++ b/slack_bolt/adapter/aws_lambda/__init__.py @@ -1 +1 @@ -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/bottle/__init__.py b/slack_bolt/adapter/bottle/__init__.py index f08c97a5f..df8fd9d79 100644 --- a/slack_bolt/adapter/bottle/__init__.py +++ b/slack_bolt/adapter/bottle/__init__.py @@ -1 +1 @@ -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/cherrypy/__init__.py b/slack_bolt/adapter/cherrypy/__init__.py index f08c97a5f..df8fd9d79 100644 --- a/slack_bolt/adapter/cherrypy/__init__.py +++ b/slack_bolt/adapter/cherrypy/__init__.py @@ -1 +1 @@ -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/django/__init__.py b/slack_bolt/adapter/django/__init__.py index f08c97a5f..df8fd9d79 100644 --- a/slack_bolt/adapter/django/__init__.py +++ b/slack_bolt/adapter/django/__init__.py @@ -1 +1 @@ -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/django/handler.py b/slack_bolt/adapter/django/handler.py index 7d86adfbe..5a4ffe71e 100644 --- a/slack_bolt/adapter/django/handler.py +++ b/slack_bolt/adapter/django/handler.py @@ -142,8 +142,8 @@ def __init__(self, app: App): # type: ignore # it's okay to skip calling the same connection clean-up method at the listener completion. message = """As you've already set app.listener_runner.listener_start_handler to your own one, Bolt skipped to set it to slack_sdk.adapter.django.DjangoListenerStartHandler. - - If you go with your own handler here, we highly recommend having the following lines of code + + If you go with your own handler here, we highly recommend having the following lines of code in your handle() method to clean up unmanaged stale/old database connections: from django.db import close_old_connections diff --git a/slack_bolt/adapter/falcon/__init__.py b/slack_bolt/adapter/falcon/__init__.py index e1a06662c..e54d2f1fc 100644 --- a/slack_bolt/adapter/falcon/__init__.py +++ b/slack_bolt/adapter/falcon/__init__.py @@ -1,2 +1,2 @@ # Don't add async module imports here -from .resource import SlackAppResource +from .resource import SlackAppResource # noqa: F401 diff --git a/slack_bolt/adapter/flask/__init__.py b/slack_bolt/adapter/flask/__init__.py index f08c97a5f..df8fd9d79 100644 --- a/slack_bolt/adapter/flask/__init__.py +++ b/slack_bolt/adapter/flask/__init__.py @@ -1 +1 @@ -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/pyramid/__init__.py b/slack_bolt/adapter/pyramid/__init__.py index f08c97a5f..df8fd9d79 100644 --- a/slack_bolt/adapter/pyramid/__init__.py +++ b/slack_bolt/adapter/pyramid/__init__.py @@ -1 +1 @@ -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/sanic/__init__.py b/slack_bolt/adapter/sanic/__init__.py index cf7d5ec69..02ee77873 100644 --- a/slack_bolt/adapter/sanic/__init__.py +++ b/slack_bolt/adapter/sanic/__init__.py @@ -1 +1 @@ -from .async_handler import AsyncSlackRequestHandler +from .async_handler import AsyncSlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/socket_mode/__init__.py b/slack_bolt/adapter/socket_mode/__init__.py index fbb17b0f7..0a00e1c11 100644 --- a/slack_bolt/adapter/socket_mode/__init__.py +++ b/slack_bolt/adapter/socket_mode/__init__.py @@ -4,7 +4,7 @@ * `slack_bolt.adapter.socket_mode.websocket_client` * `slack_bolt.adapter.socket_mode.aiohttp` * `slack_bolt.adapter.socket_mode.websockets` -""" +""" # noqa: E501 # Don't add async module imports here -from .builtin import SocketModeHandler # noqa +from .builtin import SocketModeHandler # noqa: F401 diff --git a/slack_bolt/adapter/starlette/__init__.py b/slack_bolt/adapter/starlette/__init__.py index 118f4bab1..848662494 100644 --- a/slack_bolt/adapter/starlette/__init__.py +++ b/slack_bolt/adapter/starlette/__init__.py @@ -1,2 +1,2 @@ # Don't add async module imports here -from .handler import SlackRequestHandler +from .handler import SlackRequestHandler # noqa: F401 diff --git a/slack_bolt/adapter/tornado/__init__.py b/slack_bolt/adapter/tornado/__init__.py index dfda87bf3..fa4896201 100644 --- a/slack_bolt/adapter/tornado/__init__.py +++ b/slack_bolt/adapter/tornado/__init__.py @@ -1 +1 @@ -from .handler import SlackEventsHandler, SlackOAuthHandler +from .handler import SlackEventsHandler, SlackOAuthHandler # noqa: F401 diff --git a/slack_bolt/app/__init__.py b/slack_bolt/app/__init__.py index de3ea4c23..b99c2c430 100644 --- a/slack_bolt/app/__init__.py +++ b/slack_bolt/app/__init__.py @@ -6,4 +6,4 @@ """ # Don't add async module imports here -from .app import App # type: ignore +from .app import App # noqa: F401 type: ignore diff --git a/slack_bolt/async_app.py b/slack_bolt/async_app.py index 5b17d8251..ed924f13b 100644 --- a/slack_bolt/async_app.py +++ b/slack_bolt/async_app.py @@ -43,7 +43,7 @@ async def command(ack, body, respond): Apps can be run the same way as the synchronous example above. If you'd prefer another async Web framework (e.g., Sanic, FastAPI, Starlette), take a look at [the built-in adapters](https://github.com/slackapi/bolt-python/tree/main/slack_bolt/adapter) and their corresponding [examples](https://github.com/slackapi/bolt-python/tree/main/examples). Refer to `slack_bolt.app.async_app` for more details. -""" +""" # noqa: E501 from .app.async_app import AsyncApp # noqa from .context.ack.async_ack import AsyncAck # noqa from .context.async_context import AsyncBoltContext # noqa diff --git a/slack_bolt/authorization/__init__.py b/slack_bolt/authorization/__init__.py index 2e7e988f3..9ea3c8da5 100644 --- a/slack_bolt/authorization/__init__.py +++ b/slack_bolt/authorization/__init__.py @@ -3,4 +3,4 @@ Refer to https://slack.dev/bolt-python/concepts#authorization for details. """ -from .authorize_result import AuthorizeResult +from .authorize_result import AuthorizeResult # noqa diff --git a/slack_bolt/context/__init__.py b/slack_bolt/context/__init__.py index fabbfae98..951e00828 100644 --- a/slack_bolt/context/__init__.py +++ b/slack_bolt/context/__init__.py @@ -6,4 +6,4 @@ """ # Don't add async module imports here -from .context import BoltContext +from .context import BoltContext # noqa: F401 diff --git a/slack_bolt/context/ack/__init__.py b/slack_bolt/context/ack/__init__.py index 2f150ce24..8e5767113 100644 --- a/slack_bolt/context/ack/__init__.py +++ b/slack_bolt/context/ack/__init__.py @@ -1,2 +1,2 @@ # Don't add async module imports here -from .ack import Ack +from .ack import Ack # noqa: F401 diff --git a/slack_bolt/context/ack/internals.py b/slack_bolt/context/ack/internals.py index 965033b77..1a9ca92e8 100644 --- a/slack_bolt/context/ack/internals.py +++ b/slack_bolt/context/ack/internals.py @@ -61,7 +61,7 @@ def _set_response( ) else: raise ValueError( - f"errors field is required for response_action: errors" + "errors field is required for response_action: errors" ) else: body = {"response_action": response_action} diff --git a/slack_bolt/context/respond/__init__.py b/slack_bolt/context/respond/__init__.py index 2b240ebab..135f87277 100644 --- a/slack_bolt/context/respond/__init__.py +++ b/slack_bolt/context/respond/__init__.py @@ -1,2 +1,2 @@ # Don't add async module imports here -from .respond import Respond +from .respond import Respond # noqa: F401 diff --git a/slack_bolt/context/say/__init__.py b/slack_bolt/context/say/__init__.py index 828ad8877..82dad6a7f 100644 --- a/slack_bolt/context/say/__init__.py +++ b/slack_bolt/context/say/__init__.py @@ -1,2 +1,2 @@ # Don't add async module imports here -from .say import Say +from .say import Say # noqa: F401 diff --git a/slack_bolt/kwargs_injection/__init__.py b/slack_bolt/kwargs_injection/__init__.py index 8d8d1e6ac..56e1fa53e 100644 --- a/slack_bolt/kwargs_injection/__init__.py +++ b/slack_bolt/kwargs_injection/__init__.py @@ -5,5 +5,5 @@ """ # Don't add async module imports here -from .args import Args -from .utils import build_required_kwargs +from .args import Args # noqa: F401 +from .utils import build_required_kwargs # noqa: F401 diff --git a/slack_bolt/kwargs_injection/utils.py b/slack_bolt/kwargs_injection/utils.py index f0ad186a4..617e4de03 100644 --- a/slack_bolt/kwargs_injection/utils.py +++ b/slack_bolt/kwargs_injection/utils.py @@ -1,7 +1,7 @@ # pytype: skip-file import inspect import logging -from typing import Callable, Dict, Optional, Any, Sequence, List +from typing import Callable, Dict, Optional, Any, Sequence from slack_bolt.request import BoltRequest from slack_bolt.response import BoltResponse diff --git a/slack_bolt/lazy_listener/async_runner.py b/slack_bolt/lazy_listener/async_runner.py index b98eb5492..a42098e06 100644 --- a/slack_bolt/lazy_listener/async_runner.py +++ b/slack_bolt/lazy_listener/async_runner.py @@ -1,6 +1,6 @@ from abc import abstractmethod, ABCMeta from logging import Logger -from typing import Callable, Awaitable, Any, Coroutine +from typing import Callable, Awaitable from slack_bolt.lazy_listener.async_internals import to_runnable_function from slack_bolt.request.async_request import AsyncBoltRequest diff --git a/slack_bolt/listener/builtins.py b/slack_bolt/listener/builtins.py index 66784d182..ee5891f27 100644 --- a/slack_bolt/listener/builtins.py +++ b/slack_bolt/listener/builtins.py @@ -1,5 +1,3 @@ -from slack_sdk.oauth import InstallationStore - from slack_bolt.context.context import BoltContext from slack_sdk.oauth.installation_store.installation_store import InstallationStore diff --git a/slack_bolt/listener_matcher/builtins.py b/slack_bolt/listener_matcher/builtins.py index 043a497fa..ecac0012a 100644 --- a/slack_bolt/listener_matcher/builtins.py +++ b/slack_bolt/listener_matcher/builtins.py @@ -29,8 +29,7 @@ from re import _pattern_type as Pattern else: from re import Pattern -from typing import Callable, Awaitable, Any, Sequence, Optional, Union -from typing import Union, Optional, Dict +from typing import Callable, Awaitable, Any, Sequence, Optional, Union, Dict from slack_bolt.kwargs_injection import build_required_kwargs from slack_bolt.request import BoltRequest diff --git a/slack_bolt/logger/messages.py b/slack_bolt/logger/messages.py index 4920991b8..b9e94b52b 100644 --- a/slack_bolt/logger/messages.py +++ b/slack_bolt/logger/messages.py @@ -348,4 +348,7 @@ def debug_return_listener_middleware_response( listener_name: str, status: int, body: str, starting_time: float ) -> str: millis = int((time.time() - starting_time) * 1000) - return f"Responding with listener middleware's response - listener: {listener_name}, status: {status}, body: {body} ({millis} millis)" + return ( + "Responding with listener middleware's response - " + f"listener: {listener_name}, status: {status}, body: {body} ({millis} millis)" + ) diff --git a/slack_bolt/middleware/__init__.py b/slack_bolt/middleware/__init__.py index 752c1259f..a21747e92 100644 --- a/slack_bolt/middleware/__init__.py +++ b/slack_bolt/middleware/__init__.py @@ -6,13 +6,16 @@ """ # Don't add async module imports here -from .authorization import SingleTeamAuthorization, MultiTeamsAuthorization -from .custom_middleware import CustomMiddleware -from .ignoring_self_events import IgnoringSelfEvents -from .middleware import Middleware -from .request_verification import RequestVerification -from .ssl_check import SslCheck -from .url_verification import UrlVerification +from .authorization import ( + SingleTeamAuthorization, + MultiTeamsAuthorization, +) # noqa: F401 +from .custom_middleware import CustomMiddleware # noqa: F401 +from .ignoring_self_events import IgnoringSelfEvents # noqa: F401 +from .middleware import Middleware # noqa: F401 +from .request_verification import RequestVerification # noqa: F401 +from .ssl_check import SslCheck # noqa: F401 +from .url_verification import UrlVerification # noqa: F401 builtin_middleware_classes = [ SslCheck, diff --git a/slack_bolt/middleware/async_builtins.py b/slack_bolt/middleware/async_builtins.py index 09b5338e0..46cef9003 100644 --- a/slack_bolt/middleware/async_builtins.py +++ b/slack_bolt/middleware/async_builtins.py @@ -1,11 +1,11 @@ -from .ignoring_self_events.async_ignoring_self_events import ( +from .ignoring_self_events.async_ignoring_self_events import ( # noqa: F401 AsyncIgnoringSelfEvents, -) # noqa -from .request_verification.async_request_verification import ( +) +from .request_verification.async_request_verification import ( # noqa: F401 AsyncRequestVerification, -) # noqa -from .ssl_check.async_ssl_check import AsyncSslCheck # noqa -from .url_verification.async_url_verification import AsyncUrlVerification # noqa -from .message_listener_matches.async_message_listener_matches import ( +) +from .ssl_check.async_ssl_check import AsyncSslCheck # noqa: F401 +from .url_verification.async_url_verification import AsyncUrlVerification # noqa: F401 +from .message_listener_matches.async_message_listener_matches import ( # noqa: F401 AsyncMessageListenerMatches, -) # noqa +) diff --git a/slack_bolt/middleware/authorization/__init__.py b/slack_bolt/middleware/authorization/__init__.py index 832947b45..fd5b10263 100644 --- a/slack_bolt/middleware/authorization/__init__.py +++ b/slack_bolt/middleware/authorization/__init__.py @@ -1,4 +1,4 @@ # Don't add async module imports here -from .authorization import Authorization -from .multi_teams_authorization import MultiTeamsAuthorization -from .single_team_authorization import SingleTeamAuthorization +from .authorization import Authorization # noqa: F401 +from .multi_teams_authorization import MultiTeamsAuthorization # noqa: F401 +from .single_team_authorization import SingleTeamAuthorization # noqa: F401 diff --git a/slack_bolt/middleware/ssl_check/ssl_check.py b/slack_bolt/middleware/ssl_check/ssl_check.py index d8c92c72d..5e61773cd 100644 --- a/slack_bolt/middleware/ssl_check/ssl_check.py +++ b/slack_bolt/middleware/ssl_check/ssl_check.py @@ -23,7 +23,7 @@ def __init__( verification_token: The verification token to check (optional as it's already deprecated - https://api.slack.com/authentication/verifying-requests-from-slack#verification_token_deprecation) base_logger: The base logger - """ + """ # noqa: E501 self.verification_token = verification_token self.logger = get_bolt_logger(SslCheck, base_logger=base_logger) diff --git a/slack_bolt/oauth/internals.py b/slack_bolt/oauth/internals.py index 9fedc6e8f..1929f791a 100644 --- a/slack_bolt/oauth/internals.py +++ b/slack_bolt/oauth/internals.py @@ -91,7 +91,7 @@ def _build_default_install_page_html(url: str) -> str:

-""" +""" # noqa: E501 # key: client_id, value: InstallationStore diff --git a/slack_bolt/request/__init__.py b/slack_bolt/request/__init__.py index e8dff275e..402d70cde 100644 --- a/slack_bolt/request/__init__.py +++ b/slack_bolt/request/__init__.py @@ -4,4 +4,4 @@ This interface encapsulates the difference between the two. """ # Don't add async module imports here -from .request import BoltRequest +from .request import BoltRequest # noqa: F401 diff --git a/slack_bolt/response/__init__.py b/slack_bolt/response/__init__.py index a159c701e..2dfd1d695 100644 --- a/slack_bolt/response/__init__.py +++ b/slack_bolt/response/__init__.py @@ -6,4 +6,4 @@ Refer to https://api.slack.com/apis/connections for the two types of connections. """ -from .response import BoltResponse +from .response import BoltResponse # noqa: F401 diff --git a/slack_bolt/workflows/step/__init__.py b/slack_bolt/workflows/step/__init__.py index 8bd0a067a..9418a2e4c 100644 --- a/slack_bolt/workflows/step/__init__.py +++ b/slack_bolt/workflows/step/__init__.py @@ -1,6 +1,6 @@ -from .step import WorkflowStep -from .step_middleware import WorkflowStepMiddleware -from .utilities.complete import Complete -from .utilities.configure import Configure -from .utilities.update import Update -from .utilities.fail import Fail +from .step import WorkflowStep # noqa: F401 +from .step_middleware import WorkflowStepMiddleware # noqa: F401 +from .utilities.complete import Complete # noqa: F401 +from .utilities.configure import Configure # noqa: F401 +from .utilities.update import Update # noqa: F401 +from .utilities.fail import Fail # noqa: F401 diff --git a/slack_bolt/workflows/step/async_step.py b/slack_bolt/workflows/step/async_step.py index 113c6c346..c8de638ca 100644 --- a/slack_bolt/workflows/step/async_step.py +++ b/slack_bolt/workflows/step/async_step.py @@ -230,11 +230,11 @@ def build(self, base_logger: Optional[Logger] = None) -> "AsyncWorkflowStep": An `AsyncWorkflowStep` object """ if self._edit is None: - raise BoltError(f"edit listener is not registered") + raise BoltError("edit listener is not registered") if self._save is None: - raise BoltError(f"save listener is not registered") + raise BoltError("save listener is not registered") if self._execute is None: - raise BoltError(f"execute listener is not registered") + raise BoltError("execute listener is not registered") return AsyncWorkflowStep( callback_id=self.callback_id, diff --git a/slack_bolt/workflows/step/step.py b/slack_bolt/workflows/step/step.py index dd17289fe..6c944af66 100644 --- a/slack_bolt/workflows/step/step.py +++ b/slack_bolt/workflows/step/step.py @@ -220,11 +220,11 @@ def build(self, base_logger: Optional[Logger] = None) -> "WorkflowStep": WorkflowStep object """ if self._edit is None: - raise BoltError(f"edit listener is not registered") + raise BoltError("edit listener is not registered") if self._save is None: - raise BoltError(f"save listener is not registered") + raise BoltError("save listener is not registered") if self._execute is None: - raise BoltError(f"execute listener is not registered") + raise BoltError("execute listener is not registered") return WorkflowStep( callback_id=self.callback_id, From d29bbb761ef2a86fb626eb14ebed2b4c25b70dea Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Sat, 23 Apr 2022 21:23:20 +0900 Subject: [PATCH 2/5] Fix the GitHub Action label --- .github/workflows/flake8.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index f13674516..0c24f97c1 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -1,4 +1,4 @@ -name: Run pytype validation +name: Run flake8 validation on: push: From 1c174fc6bda4f1e20198f453ff482fa2d2676ead Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 25 Apr 2022 08:31:57 -0700 Subject: [PATCH 3/5] Update scripts/run_flake8.sh Co-authored-by: Fil Maj --- scripts/run_flake8.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_flake8.sh b/scripts/run_flake8.sh index 59cd510e6..d9ec07ff6 100755 --- a/scripts/run_flake8.sh +++ b/scripts/run_flake8.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ./scripts/run_pytype.sh +# ./scripts/run_flake8.sh script_dir=$(dirname $0) cd ${script_dir}/.. && \ From 95dfebdbb19c1be339360fb009c01f548ab5769e Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 25 Apr 2022 08:32:39 -0700 Subject: [PATCH 4/5] Update .github/workflows/flake8.yml --- .github/workflows/flake8.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index 0c24f97c1..b9e0414b7 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -20,4 +20,4 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run pytype verification run: | - ./scripts/run_pytype.sh + ./scripts/run_flake8.sh From 990b615a9c6cd2b2fae6df035cd4ca763468815d Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 25 Apr 2022 08:58:12 -0700 Subject: [PATCH 5/5] Update .github/workflows/flake8.yml --- .github/workflows/flake8.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index b9e0414b7..74a0d86b8 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -18,6 +18,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Run pytype verification + - name: Run flake8 verification run: | ./scripts/run_flake8.sh