Skip to content

Commit f00fa90

Browse files
clean things up based on feedback
1 parent 462ef6f commit f00fa90

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

slack_sdk/web/internal_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,12 @@ def _to_0_or_1_if_bool(v: Any) -> Union[Any, str]:
249249

250250
def _warn_if_message_text_content_is_missing(endpoint: str, kwargs: Dict[str, Any]) -> None:
251251
text = kwargs.get("text")
252-
markdown_text = kwargs.get("markdown_text")
253-
if (text and len(text.strip()) > 0) or (markdown_text and len(markdown_text.strip()) > 0):
252+
if text and len(text.strip()) > 0:
254253
# If a top-level text arg is provided, we are good. This is the recommended accessibility field to always provide.
254+
return
255+
256+
markdown_text = kwargs.get("markdown_text")
257+
if markdown_text and len(markdown_text.strip()) > 0:
255258
# If a top-level markdown_text arg is provided, we are good. It should not be used in conjunction with text.
256259
return
257260

tests/slack_sdk_async/web/test_web_client_msg_text_content_warnings.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,43 +75,43 @@ async def test_missing_fallback_warning_chat_update(self):
7575
with self.assertWarnsRegex(UserWarning, "`text` argument is missing"):
7676
resp = await client.chat_update(channel="C111", ts="111.222", blocks=[], attachments=[{"text": "hi"}])
7777
self.assertIsNone(resp["error"])
78-
78+
7979
@async_test
80-
def test_no_warning_when_markdown_text_is_provided_chat_postMessage(self):
81-
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
80+
async def test_no_warning_when_markdown_text_is_provided_chat_postMessage(self):
81+
client = AsyncWebClient(base_url="http://localhost:8888", token="xoxb-api_test")
8282
with warnings.catch_warnings(record=True) as warning_list:
8383
warnings.simplefilter("always")
84-
resp = client.chat_postMessage(channel="C111", markdown_text="# hello")
84+
resp = await client.chat_postMessage(channel="C111", markdown_text="# hello")
8585

8686
self.assertEqual(warning_list, [])
8787
self.assertIsNone(resp["error"])
8888

8989
@async_test
90-
def test_no_warning_when_markdown_text_is_provided_chat_postEphemeral(self):
91-
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
90+
async def test_no_warning_when_markdown_text_is_provided_chat_postEphemeral(self):
91+
client = AsyncWebClient(base_url="http://localhost:8888", token="xoxb-api_test")
9292
with warnings.catch_warnings(record=True) as warning_list:
9393
warnings.simplefilter("always")
94-
resp = client.chat_postEphemeral(channel="C111", user="U111", markdown_text="# hello")
94+
resp = await client.chat_postEphemeral(channel="C111", user="U111", markdown_text="# hello")
9595

9696
self.assertEqual(warning_list, [])
9797
self.assertIsNone(resp["error"])
9898

9999
@async_test
100-
def test_no_warning_when_markdown_text_is_provided_chat_scheduleMessage(self):
101-
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
100+
async def test_no_warning_when_markdown_text_is_provided_chat_scheduleMessage(self):
101+
client = AsyncWebClient(base_url="http://localhost:8888", token="xoxb-api_test")
102102
with warnings.catch_warnings(record=True) as warning_list:
103103
warnings.simplefilter("always")
104-
resp = client.chat_scheduleMessage(channel="C111", post_at="299876400", markdown_text="# hello")
104+
resp = await client.chat_scheduleMessage(channel="C111", post_at="299876400", markdown_text="# hello")
105105

106106
self.assertEqual(warning_list, [])
107107
self.assertIsNone(resp["error"])
108108

109109
@async_test
110-
def test_no_warning_when_markdown_text_is_provided_chat_update(self):
111-
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
110+
async def test_no_warning_when_markdown_text_is_provided_chat_update(self):
111+
client = AsyncWebClient(base_url="http://localhost:8888", token="xoxb-api_test")
112112
with warnings.catch_warnings(record=True) as warning_list:
113113
warnings.simplefilter("always")
114-
resp = client.chat_update(channel="C111", ts="111.222", markdown_text="# hello")
114+
resp = await client.chat_update(channel="C111", ts="111.222", markdown_text="# hello")
115115

116116
self.assertEqual(warning_list, [])
117117
self.assertIsNone(resp["error"])

0 commit comments

Comments
 (0)