Skip to content

Fix #1127 Add more docstrings to slack_sdk.models classes#1135

Merged
seratch merged 2 commits intoslackapi:mainfrom
seratch:issue-1127-models-docstring
Nov 19, 2021
Merged

Fix #1127 Add more docstrings to slack_sdk.models classes#1135
seratch merged 2 commits intoslackapi:mainfrom
seratch:issue-1127-models-docstring

Conversation

@seratch
Copy link
Copy Markdown
Contributor

@seratch seratch commented Nov 15, 2021

Summary

This pull request fixes #1127 by adding docstring to the Block Kit model classes. While working on this, I've noticed there are a few unusable arguments in some classes. I've removed them as well.

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs-src (Documents, have you run ./scripts/docs.sh?)
  • /docs-src-v2 (Documents, have you run ./scripts/docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

@seratch seratch added enhancement M-T: A feature request for new functionality web-client Version: 3x labels Nov 15, 2021
@seratch seratch added this to the 3.12.0 milestone Nov 15, 2021
@seratch seratch self-assigned this Nov 15, 2021

attributes = {"type", "action_id", "placeholder", "confirm"}

def _subtype_warning(self):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already defined in the super class. We can safely remove this overridden one

self,
*,
action_id: Optional[str] = None,
placeholder: Optional[str] = None,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button block element does not accept placeholder. This has been wrong for a long time.

"""
This select menu will load its options from an external data source, allowing
for a dynamic list of options.
https://api.slack.com/reference/block-kit/block-elements#external-select
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document URL was wrong

*,
action_id: Optional[str] = None,
placeholder: Optional[Union[str, dict, TextObject]] = None,
confirm: Optional[Union[dict, ConfirmObject]] = None,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input block element does not accept confirm object. This has been wrong for a long time.

self,
*,
action_id: Optional[str] = None,
placeholder: Optional[Union[str, dict, TextObject]] = None,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Radio buttons block element does not accept placeholder. This has been wrong for a long time.

text=STRING_301_CHARS, action_id="button", value="click_me"
).to_dict()

def test_action_id_length(self):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implemented in its super class. Just in case, I've added more tests for it.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 15, 2021

Codecov Report

Merging #1135 (e2a1ce6) into main (cf22599) will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1135      +/-   ##
==========================================
- Coverage   86.62%   86.60%   -0.03%     
==========================================
  Files         110      110              
  Lines       10749    10747       -2     
==========================================
- Hits         9311     9307       -4     
- Misses       1438     1440       +2     
Impacted Files Coverage Δ
slack_sdk/models/blocks/basic_components.py 87.12% <ø> (ø)
slack_sdk/models/blocks/block_elements.py 92.51% <ø> (+0.20%) ⬆️
slack_sdk/models/blocks/blocks.py 96.26% <ø> (ø)
slack_sdk/socket_mode/builtin/internals.py 70.66% <0.00%> (-1.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf22599...e2a1ce6. Read the comment docs.

Copy link
Copy Markdown
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the smell of docs first thing Monday morning. Thanks for doing this, looks great! Left one tiny comment. :shipit:

Should be unique among all other action_ids in the containing block.
Maximum length for this field is 255 characters.
options (required): An array of option objects. A maximum of 10 options are allowed.
initial_options: An array of option objects that exactly matches one or more of the options within options.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this text is taken from the checkboxes docs, but because we lack linking like the docs site has, some of the context is lost here. May I suggest we expand this a bit to make it clear which "options" are being talked about within the sentence (we are both talking about the options argument as well as the concept of options!)?

Suggested change
initial_options: An array of option objects that exactly matches one or more of the options within options.
initial_options: An array of option objects that exactly matches one or more of the options provided to the `options` argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. Indeed, the sentence here does not make sense 😓 Although I don't want to have so many edits on these (as these are taken from the API documents) but will adjust some parts like this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

57698054

Copy link
Copy Markdown
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition! I only found one small typo and left a suggestion for it.

block_id should be unique for each message or view and each iteration of a message or view.
If a message or view is updated, use a new block_id.
hint: An optional hint that appears below an input element in a lighter grey.
It must be a a text object with a type of plain_text.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It must be a a text object with a type of plain_text.
It must be a text object with a type of plain_text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Perhaps, I need to send a patch to the original document as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seratch Ah, I didn't realize you borrowed it directly from api.slack.com. I can send a patch for the original documentation and add you as a reviewer 👍🏻

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks You are so quick 🚀 Thank you!

@seratch seratch merged commit 1de0d2a into slackapi:main Nov 19, 2021
@seratch seratch deleted the issue-1127-models-docstring branch November 19, 2021 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality Version: 3x web-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add more docstrings to slack_sdk.models classes

3 participants