Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions slack/web/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import warnings

# https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api
deprecated_method_prefixes_2020_01 = ["channels.", "groups.", "im.", "mpim."]


def show_2020_01_deprecation(method_name: str):
skip_deprecation = os.environ.get(
"SLACKCLIENT_SKIP_DEPRECATION"
) # for unit tests etc.
if skip_deprecation:
return
if not method_name:
return

matched_prefixes = [
prefix
for prefix in deprecated_method_prefixes_2020_01
if method_name.startswith(prefix)
]
if len(matched_prefixes) > 0:
message = (
f"{method_name} is deprecated. Please use the Conversations API instead. "
"For more info, go to "
"https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api"
)
warnings.warn(message)
2 changes: 2 additions & 0 deletions slack/web/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from aiohttp import FormData, BasicAuth

# Internal Imports
from slack.web import show_2020_01_deprecation
from slack.web.slack_response import SlackResponse
import slack.version as ver
import slack.errors as err
Expand Down Expand Up @@ -170,6 +171,7 @@ def api_call(
if self._event_loop is None:
self._event_loop = self._get_event_loop()

show_2020_01_deprecation(api_method)
future = asyncio.ensure_future(
self._send(http_verb=http_verb, api_url=api_url, req_args=req_args),
loop=self._event_loop,
Expand Down
2 changes: 2 additions & 0 deletions tests/web/test_web_client_coverage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Standard Imports
import os
import unittest

# ThirdParty Imports
Expand All @@ -17,6 +18,7 @@ class TestWebClientCoverage(unittest.TestCase):
)

api_methods_to_call = []
os.environ.setdefault("SLACKCLIENT_SKIP_DEPRECATION", "1")

def setUp(self):
self.loop = asyncio.new_event_loop()
Expand Down