Skip to content

Commit

Permalink
version 3.16.1
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed May 10, 2022
1 parent 0258e40 commit 3727a6e
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 113 deletions.
265 changes: 220 additions & 45 deletions docs/api-docs/slack_sdk/audit_logs/v1/logs.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api-docs/slack_sdk/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1 class="title">Module <code>slack_sdk.version</code></h1>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Check the latest version at https://pypi.org/project/slack-sdk/&#34;&#34;&#34;
__version__ = &#34;3.16.0&#34;</code></pre>
__version__ = &#34;3.16.1&#34;</code></pre>
</details>
</section>
<section>
Expand Down
26 changes: 13 additions & 13 deletions docs/api-docs/slack_sdk/web/async_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
from .internal_utils import (
_parse_web_class_objects,
_update_call_participants,
_warn_if_text_is_missing,
_warn_if_text_or_attachment_fallback_is_missing,
_remove_none_values,
)
from ..models.attachments import Attachment
Expand Down Expand Up @@ -2104,7 +2104,7 @@ <h1 class="title">Module <code>slack_sdk.web.async_client</code></h1>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return await self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)

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

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

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

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

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

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

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

Expand Down Expand Up @@ -12328,7 +12328,7 @@ <h3>Methods</h3>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return await self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)</code></pre>
</details>
Expand Down Expand Up @@ -12393,7 +12393,7 @@ <h3>Methods</h3>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return await self.api_call(&#34;chat.postMessage&#34;, json=kwargs)</code></pre>
</details>
Expand Down Expand Up @@ -12448,7 +12448,7 @@ <h3>Methods</h3>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return await self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)</code></pre>
</details>
Expand Down Expand Up @@ -12580,7 +12580,7 @@ <h3>Methods</h3>
kwargs.update({&#34;file_ids&#34;: file_ids})
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
# NOTE: intentionally using json over params for API methods using blocks/attachments
return await self.api_call(&#34;chat.update&#34;, json=kwargs)</code></pre>
</details>
Expand Down
26 changes: 13 additions & 13 deletions docs/api-docs/slack_sdk/web/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
from .internal_utils import (
_parse_web_class_objects,
_update_call_participants,
_warn_if_text_is_missing,
_warn_if_text_or_attachment_fallback_is_missing,
_remove_none_values,
)
from ..models.attachments import Attachment
Expand Down Expand Up @@ -2053,7 +2053,7 @@ <h1 class="title">Module <code>slack_sdk.web.client</code></h1>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)

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

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

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

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

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

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

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

Expand Down Expand Up @@ -12153,7 +12153,7 @@ <h3>Methods</h3>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postEphemeral&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return self.api_call(&#34;chat.postEphemeral&#34;, json=kwargs)</code></pre>
</details>
Expand Down Expand Up @@ -12218,7 +12218,7 @@ <h3>Methods</h3>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.postMessage&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.postMessage&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return self.api_call(&#34;chat.postMessage&#34;, json=kwargs)</code></pre>
</details>
Expand Down Expand Up @@ -12273,7 +12273,7 @@ <h3>Methods</h3>
)
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.scheduleMessage&#34;, kwargs)
# NOTE: intentionally using json over params for the API methods using blocks/attachments
return self.api_call(&#34;chat.scheduleMessage&#34;, json=kwargs)</code></pre>
</details>
Expand Down Expand Up @@ -12405,7 +12405,7 @@ <h3>Methods</h3>
kwargs.update({&#34;file_ids&#34;: file_ids})
_parse_web_class_objects(kwargs)
kwargs = _remove_none_values(kwargs)
_warn_if_text_is_missing(&#34;chat.update&#34;, kwargs)
_warn_if_text_or_attachment_fallback_is_missing(&#34;chat.update&#34;, kwargs)
# NOTE: intentionally using json over params for API methods using blocks/attachments
return self.api_call(&#34;chat.update&#34;, json=kwargs)</code></pre>
</details>
Expand Down
68 changes: 41 additions & 27 deletions docs/api-docs/slack_sdk/web/internal_utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,41 +269,55 @@ <h1 class="title">Module <code>slack_sdk.web.internal_utils</code></h1>
return v


def _warn_if_text_is_missing(endpoint: str, kwargs: Dict[str, Any]) -&gt; None:
missing = &#34;text&#34;
def _warn_if_text_or_attachment_fallback_is_missing(
endpoint: str, kwargs: Dict[str, Any]
) -&gt; None:
text = kwargs.get(&#34;text&#34;)
if text and len(text.strip()) &gt; 0:
# If a top-level text arg is provided, we are good. This is the recommended accessibility field to always provide.
return

# for unit tests etc.
skip_deprecation = os.environ.get(&#34;SKIP_SLACK_SDK_WARNING&#34;)
if skip_deprecation:
return

# At this point, at a minimum, text argument is missing. Warn the user about this.
message = (
f&#34;The top-level `text` argument is missing in the request payload for a {endpoint} call - &#34;
f&#34;It&#39;s a best practice to always provide a `text` argument when posting a message. &#34;
f&#34;The `text` argument is used in places where content cannot be rendered such as: &#34;
&#34;system push notifications, assistive technology such as screen readers, etc.&#34;
)
warnings.warn(message, UserWarning)

# Additionally, specifically for attachments, there is a legacy field available at the attachment level called `fallback`
# Even with a missing text, one can provide a `fallback` per attachment.
# More details here: https://api.slack.com/reference/messaging/attachments#legacy_fields
attachments = kwargs.get(&#34;attachments&#34;)
# Note that this method does not verify attachments
# if the value is already serialized as a single str value.
if attachments is not None and isinstance(attachments, list):
# https://api.slack.com/reference/messaging/attachments
# Check if the fallback field exists for all the attachments
if all(
if (
attachments is not None
and isinstance(attachments, list)
and not all(
[
isinstance(attachment, dict)
and len(attachment.get(&#34;fallback&#34;, &#34;&#34;).strip()) &gt; 0
for attachment in attachments
]
):
# The attachments are all good
return
missing = &#34;fallback&#34;
else:
text = kwargs.get(&#34;text&#34;)
if text and len(text.strip()) &gt; 0:
# Note that this is applicable only for blocks.
return

message = (
f&#34;The `{missing}` argument is missing in the request payload for a {endpoint} call - &#34;
f&#34;It&#39;s a best practice to always provide a `{missing}` argument when posting a message. &#34;
f&#34;The `{missing}` argument is used in places where content cannot be rendered such as: &#34;
&#34;system push notifications, assistive technology such as screen readers, etc.&#34;
)
# for unit tests etc.
skip_deprecation = os.environ.get(&#34;SKIP_SLACK_SDK_WARNING&#34;)
if skip_deprecation:
return
warnings.warn(message, UserWarning)
)
):
# https://api.slack.com/reference/messaging/attachments
# Check if the fallback field exists for all the attachments
# Not all attachments have a fallback property; warn about this too!
message = (
f&#34;Additionally, the attachment-level `fallback` argument is missing in the request payload for a {endpoint} call&#34;
f&#34; - To avoid this warning, it is recommended to always provide a top-level `text` argument when posting a&#34;
f&#34; message. Alternatively you can provide an attachment-level `fallback` argument, though this is now considered&#34;
f&#34; a legacy field (see https://api.slack.com/reference/messaging/attachments#legacy_fields for more details).&#34;
)
warnings.warn(message, UserWarning)


def _build_unexpected_body_error_message(body: str) -&gt; str:
Expand Down
Loading

0 comments on commit 3727a6e

Please sign in to comment.