You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/21 18:03:03 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #25852: Refactor Slack API Hook and add new Connection type

Taragolis commented on code in PR #25852:
URL: https://github.com/apache/airflow/pull/25852#discussion_r950880873


##########
airflow/providers/slack/hooks/slack.py:
##########
@@ -15,27 +15,47 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-"""Hook for Slack"""
-from typing import Any, Optional
+
+import warnings
+from typing import TYPE_CHECKING, Any, Dict, List, Optional
 
 from slack_sdk import WebClient
-from slack_sdk.web.slack_response import SlackResponse
+from slack_sdk.errors import SlackApiError
 
-from airflow.exceptions import AirflowException
+from airflow.compat.functools import cached_property
+from airflow.exceptions import AirflowException, AirflowNotFoundException
 from airflow.hooks.base import BaseHook
+from airflow.providers.slack.utils import ConnectionExtraConfig, prefixed_extra_field
+from airflow.settings import json
+
+if TYPE_CHECKING:
+    from slack_sdk.http_retry import RetryHandler
+    from slack_sdk.web.slack_response import SlackResponse
 
 
 class SlackHook(BaseHook):
     """
-    Creates a Slack connection to be used for calls.
+    Creates a Slack API Connection to be used for calls.
+
+    This class provide a thin wrapper around the ``slack_sdk.WebClient``.
+
+    .. seealso::
+        - :ref:`Slack API connection <howto/connection:slack>`
+        - https://api.slack.com/messaging
+        - https://slack.dev/python-slack-sdk/web/index.html
+
+    .. warning::
+        This hook intend to use `Slack API` connection
+        and might not work correctly with `Slack Webhook` and `HTTP` connections.
 
     Takes both Slack API token directly and connection that has Slack API token. If both are
     supplied, Slack API token will be used. Also exposes the rest of slack.WebClient args.
+
     Examples:
-    .. code-block:: python
+     .. code-block:: python

Review Comment:
   This additional indent required to proper formatted block in documentation and PyCharm
   
   **Without additional space**
   https://airflow.apache.org/docs/apache-airflow-providers-slack/stable/_api/airflow/providers/slack/hooks/slack/index.html#airflow.providers.slack.hooks.slack.SlackHook
   
   **With additional space**
   ![image](https://user-images.githubusercontent.com/3998685/185804662-7528444c-163c-4f34-b2ad-2e495af41522.png)
   
   Might be possible avoid this "hack"?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org