Skip to content

Commit 3727a6e

Browse files
committed
version 3.16.1
1 parent 0258e40 commit 3727a6e

File tree

7 files changed

+302
-113
lines changed

7 files changed

+302
-113
lines changed

docs/api-docs/slack_sdk/audit_logs/v1/logs.html

Lines changed: 220 additions & 45 deletions
Large diffs are not rendered by default.

docs/api-docs/slack_sdk/version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="title">Module <code>slack_sdk.version</code></h1>
2828
<span>Expand source code</span>
2929
</summary>
3030
<pre><code class="python">&#34;&#34;&#34;Check the latest version at https://pypi.org/project/slack-sdk/&#34;&#34;&#34;
31-
__version__ = &#34;3.16.0&#34;</code></pre>
31+
__version__ = &#34;3.16.1&#34;</code></pre>
3232
</details>
3333
</section>
3434
<section>

docs/api-docs/slack_sdk/web/async_client.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
4848
from .internal_utils import (
4949
_parse_web_class_objects,
5050
_update_call_participants,
51-
_warn_if_text_is_missing,
51+
_warn_if_text_or_attachment_fallback_is_missing,
5252
_remove_none_values,
5353
)
5454
from ..models.attachments import Attachment
@@ -2104,7 +2104,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
21042104
)
21052105
_parse_web_class_objects(kwargs)
21062106
kwargs = _remove_none_values(kwargs)
2107-
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
2107+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
21082108
# NOTE: intentionally using json over params for the API methods using blocks/attachments
21092109
return await self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)
21102110

@@ -2158,7 +2158,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
21582158
)
21592159
_parse_web_class_objects(kwargs)
21602160
kwargs = _remove_none_values(kwargs)
2161-
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
2161+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
21622162
# NOTE: intentionally using json over params for the API methods using blocks/attachments
21632163
return await self.api_call(&#34;chat.postMessage&#34;, json=kwargs)
21642164

@@ -2202,7 +2202,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
22022202
)
22032203
_parse_web_class_objects(kwargs)
22042204
kwargs = _remove_none_values(kwargs)
2205-
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
2205+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
22062206
# NOTE: intentionally using json over params for the API methods using blocks/attachments
22072207
return await self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)
22082208

@@ -2275,7 +2275,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
22752275
kwargs.update({&#34;file_ids&#34;: file_ids})
22762276
_parse_web_class_objects(kwargs)
22772277
kwargs = _remove_none_values(kwargs)
2278-
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
2278+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
22792279
# NOTE: intentionally using json over params for API methods using blocks/attachments
22802280
return await self.api_call(&#34;chat.update&#34;, json=kwargs)
22812281

@@ -6657,7 +6657,7 @@ <h2 id="note">Note</h2>
66576657
)
66586658
_parse_web_class_objects(kwargs)
66596659
kwargs = _remove_none_values(kwargs)
6660-
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
6660+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
66616661
# NOTE: intentionally using json over params for the API methods using blocks/attachments
66626662
return await self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)
66636663

@@ -6711,7 +6711,7 @@ <h2 id="note">Note</h2>
67116711
)
67126712
_parse_web_class_objects(kwargs)
67136713
kwargs = _remove_none_values(kwargs)
6714-
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
6714+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
67156715
# NOTE: intentionally using json over params for the API methods using blocks/attachments
67166716
return await self.api_call(&#34;chat.postMessage&#34;, json=kwargs)
67176717

@@ -6755,7 +6755,7 @@ <h2 id="note">Note</h2>
67556755
)
67566756
_parse_web_class_objects(kwargs)
67576757
kwargs = _remove_none_values(kwargs)
6758-
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
6758+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
67596759
# NOTE: intentionally using json over params for the API methods using blocks/attachments
67606760
return await self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)
67616761

@@ -6828,7 +6828,7 @@ <h2 id="note">Note</h2>
68286828
kwargs.update({&#34;file_ids&#34;: file_ids})
68296829
_parse_web_class_objects(kwargs)
68306830
kwargs = _remove_none_values(kwargs)
6831-
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
6831+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
68326832
# NOTE: intentionally using json over params for API methods using blocks/attachments
68336833
return await self.api_call(&#34;chat.update&#34;, json=kwargs)
68346834

@@ -12328,7 +12328,7 @@ <h3>Methods</h3>
1232812328
)
1232912329
_parse_web_class_objects(kwargs)
1233012330
kwargs = _remove_none_values(kwargs)
12331-
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
12331+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
1233212332
# NOTE: intentionally using json over params for the API methods using blocks/attachments
1233312333
return await self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)</code></pre>
1233412334
</details>
@@ -12393,7 +12393,7 @@ <h3>Methods</h3>
1239312393
)
1239412394
_parse_web_class_objects(kwargs)
1239512395
kwargs = _remove_none_values(kwargs)
12396-
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
12396+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
1239712397
# NOTE: intentionally using json over params for the API methods using blocks/attachments
1239812398
return await self.api_call(&#34;chat.postMessage&#34;, json=kwargs)</code></pre>
1239912399
</details>
@@ -12448,7 +12448,7 @@ <h3>Methods</h3>
1244812448
)
1244912449
_parse_web_class_objects(kwargs)
1245012450
kwargs = _remove_none_values(kwargs)
12451-
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
12451+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
1245212452
# NOTE: intentionally using json over params for the API methods using blocks/attachments
1245312453
return await self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)</code></pre>
1245412454
</details>
@@ -12580,7 +12580,7 @@ <h3>Methods</h3>
1258012580
kwargs.update({&#34;file_ids&#34;: file_ids})
1258112581
_parse_web_class_objects(kwargs)
1258212582
kwargs = _remove_none_values(kwargs)
12583-
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
12583+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
1258412584
# NOTE: intentionally using json over params for API methods using blocks/attachments
1258512585
return await self.api_call(&#34;chat.update&#34;, json=kwargs)</code></pre>
1258612586
</details>

docs/api-docs/slack_sdk/web/client.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
3939
from .internal_utils import (
4040
_parse_web_class_objects,
4141
_update_call_participants,
42-
_warn_if_text_is_missing,
42+
_warn_if_text_or_attachment_fallback_is_missing,
4343
_remove_none_values,
4444
)
4545
from ..models.attachments import Attachment
@@ -2053,7 +2053,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
20532053
)
20542054
_parse_web_class_objects(kwargs)
20552055
kwargs = _remove_none_values(kwargs)
2056-
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
2056+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
20572057
# NOTE: intentionally using json over params for the API methods using blocks/attachments
20582058
return self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)
20592059

@@ -2107,7 +2107,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
21072107
)
21082108
_parse_web_class_objects(kwargs)
21092109
kwargs = _remove_none_values(kwargs)
2110-
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
2110+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
21112111
# NOTE: intentionally using json over params for the API methods using blocks/attachments
21122112
return self.api_call(&#34;chat.postMessage&#34;, json=kwargs)
21132113

@@ -2151,7 +2151,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
21512151
)
21522152
_parse_web_class_objects(kwargs)
21532153
kwargs = _remove_none_values(kwargs)
2154-
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
2154+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
21552155
# NOTE: intentionally using json over params for the API methods using blocks/attachments
21562156
return self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)
21572157

@@ -2224,7 +2224,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
22242224
kwargs.update({&#34;file_ids&#34;: file_ids})
22252225
_parse_web_class_objects(kwargs)
22262226
kwargs = _remove_none_values(kwargs)
2227-
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
2227+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
22282228
# NOTE: intentionally using json over params for API methods using blocks/attachments
22292229
return self.api_call(&#34;chat.update&#34;, json=kwargs)
22302230

@@ -6544,7 +6544,7 @@ <h2 id="note">Note</h2>
65446544
)
65456545
_parse_web_class_objects(kwargs)
65466546
kwargs = _remove_none_values(kwargs)
6547-
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
6547+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
65486548
# NOTE: intentionally using json over params for the API methods using blocks/attachments
65496549
return self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)
65506550

@@ -6598,7 +6598,7 @@ <h2 id="note">Note</h2>
65986598
)
65996599
_parse_web_class_objects(kwargs)
66006600
kwargs = _remove_none_values(kwargs)
6601-
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
6601+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
66026602
# NOTE: intentionally using json over params for the API methods using blocks/attachments
66036603
return self.api_call(&#34;chat.postMessage&#34;, json=kwargs)
66046604

@@ -6642,7 +6642,7 @@ <h2 id="note">Note</h2>
66426642
)
66436643
_parse_web_class_objects(kwargs)
66446644
kwargs = _remove_none_values(kwargs)
6645-
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
6645+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
66466646
# NOTE: intentionally using json over params for the API methods using blocks/attachments
66476647
return self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)
66486648

@@ -6715,7 +6715,7 @@ <h2 id="note">Note</h2>
67156715
kwargs.update({&#34;file_ids&#34;: file_ids})
67166716
_parse_web_class_objects(kwargs)
67176717
kwargs = _remove_none_values(kwargs)
6718-
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
6718+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
67196719
# NOTE: intentionally using json over params for API methods using blocks/attachments
67206720
return self.api_call(&#34;chat.update&#34;, json=kwargs)
67216721

@@ -12153,7 +12153,7 @@ <h3>Methods</h3>
1215312153
)
1215412154
_parse_web_class_objects(kwargs)
1215512155
kwargs = _remove_none_values(kwargs)
12156-
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
12156+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
1215712157
# NOTE: intentionally using json over params for the API methods using blocks/attachments
1215812158
return self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)</code></pre>
1215912159
</details>
@@ -12218,7 +12218,7 @@ <h3>Methods</h3>
1221812218
)
1221912219
_parse_web_class_objects(kwargs)
1222012220
kwargs = _remove_none_values(kwargs)
12221-
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
12221+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
1222212222
# NOTE: intentionally using json over params for the API methods using blocks/attachments
1222312223
return self.api_call(&#34;chat.postMessage&#34;, json=kwargs)</code></pre>
1222412224
</details>
@@ -12273,7 +12273,7 @@ <h3>Methods</h3>
1227312273
)
1227412274
_parse_web_class_objects(kwargs)
1227512275
kwargs = _remove_none_values(kwargs)
12276-
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
12276+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
1227712277
# NOTE: intentionally using json over params for the API methods using blocks/attachments
1227812278
return self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)</code></pre>
1227912279
</details>
@@ -12405,7 +12405,7 @@ <h3>Methods</h3>
1240512405
kwargs.update({&#34;file_ids&#34;: file_ids})
1240612406
_parse_web_class_objects(kwargs)
1240712407
kwargs = _remove_none_values(kwargs)
12408-
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
12408+
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
1240912409
# NOTE: intentionally using json over params for API methods using blocks/attachments
1241012410
return self.api_call(&#34;chat.update&#34;, json=kwargs)</code></pre>
1241112411
</details>

docs/api-docs/slack_sdk/web/internal_utils.html

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -269,41 +269,55 @@ <h1 class="title">Module <code>slack_sdk.web.internal_utils</code></h1>
269269
return v
270270

271271

272-
def _warn_if_text_is_missing(endpoint: str, kwargs: Dict[str, Any]) -&gt; None:
273-
missing = &#34;text&#34;
272+
def _warn_if_text_or_attachment_fallback_is_missing(
273+
endpoint: str, kwargs: Dict[str, Any]
274+
) -&gt; None:
275+
text = kwargs.get(&#34;text&#34;)
276+
if text and len(text.strip()) &gt; 0:
277+
# If a top-level text arg is provided, we are good. This is the recommended accessibility field to always provide.
278+
return
279+
280+
# for unit tests etc.
281+
skip_deprecation = os.environ.get(&#34;SKIP_SLACK_SDK_WARNING&#34;)
282+
if skip_deprecation:
283+
return
284+
285+
# At this point, at a minimum, text argument is missing. Warn the user about this.
286+
message = (
287+
f&#34;The top-level `text` argument is missing in the request payload for a {endpoint} call - &#34;
288+
f&#34;It&#39;s a best practice to always provide a `text` argument when posting a message. &#34;
289+
f&#34;The `text` argument is used in places where content cannot be rendered such as: &#34;
290+
&#34;system push notifications, assistive technology such as screen readers, etc.&#34;
291+
)
292+
warnings.warn(message, UserWarning)
293+
294+
# Additionally, specifically for attachments, there is a legacy field available at the attachment level called `fallback`
295+
# Even with a missing text, one can provide a `fallback` per attachment.
296+
# More details here: https://api.slack.com/reference/messaging/attachments#legacy_fields
274297
attachments = kwargs.get(&#34;attachments&#34;)
275298
# Note that this method does not verify attachments
276299
# if the value is already serialized as a single str value.
277-
if attachments is not None and isinstance(attachments, list):
278-
# https://api.slack.com/reference/messaging/attachments
279-
# Check if the fallback field exists for all the attachments
280-
if all(
300+
if (
301+
attachments is not None
302+
and isinstance(attachments, list)
303+
and not all(
281304
[
282305
isinstance(attachment, dict)
283306
and len(attachment.get(&#34;fallback&#34;, &#34;&#34;).strip()) &gt; 0
284307
for attachment in attachments
285308
]
286-
):
287-
# The attachments are all good
288-
return
289-
missing = &#34;fallback&#34;
290-
else:
291-
text = kwargs.get(&#34;text&#34;)
292-
if text and len(text.strip()) &gt; 0:
293-
# Note that this is applicable only for blocks.
294-
return
295-
296-
message = (
297-
f&#34;The `{missing}` argument is missing in the request payload for a {endpoint} call - &#34;
298-
f&#34;It&#39;s a best practice to always provide a `{missing}` argument when posting a message. &#34;
299-
f&#34;The `{missing}` argument is used in places where content cannot be rendered such as: &#34;
300-
&#34;system push notifications, assistive technology such as screen readers, etc.&#34;
301-
)
302-
# for unit tests etc.
303-
skip_deprecation = os.environ.get(&#34;SKIP_SLACK_SDK_WARNING&#34;)
304-
if skip_deprecation:
305-
return
306-
warnings.warn(message, UserWarning)
309+
)
310+
):
311+
# https://api.slack.com/reference/messaging/attachments
312+
# Check if the fallback field exists for all the attachments
313+
# Not all attachments have a fallback property; warn about this too!
314+
message = (
315+
f&#34;Additionally, the attachment-level `fallback` argument is missing in the request payload for a {endpoint} call&#34;
316+
f&#34; - To avoid this warning, it is recommended to always provide a top-level `text` argument when posting a&#34;
317+
f&#34; message. Alternatively you can provide an attachment-level `fallback` argument, though this is now considered&#34;
318+
f&#34; a legacy field (see https://api.slack.com/reference/messaging/attachments#legacy_fields for more details).&#34;
319+
)
320+
warnings.warn(message, UserWarning)
307321

308322

309323
def _build_unexpected_body_error_message(body: str) -&gt; str:

0 commit comments

Comments
 (0)