Fix #1127 Add more docstrings to slack_sdk.models classes#1135
Fix #1127 Add more docstrings to slack_sdk.models classes#1135seratch merged 2 commits intoslackapi:mainfrom
Conversation
|
|
||
| attributes = {"type", "action_id", "placeholder", "confirm"} | ||
|
|
||
| def _subtype_warning(self): |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
The document URL was wrong
| *, | ||
| action_id: Optional[str] = None, | ||
| placeholder: Optional[Union[str, dict, TextObject]] = None, | ||
| confirm: Optional[Union[dict, ConfirmObject]] = None, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
This is implemented in its super class. Just in case, I've added more tests for it.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
filmaj
left a comment
There was a problem hiding this comment.
I love the smell of docs first thing Monday morning. Thanks for doing this, looks great! Left one tiny comment. ![]()
| 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. |
There was a problem hiding this comment.
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!)?
| 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. |
There was a problem hiding this comment.
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.
mwbrooks
left a comment
There was a problem hiding this comment.
Nice addition! I only found one small typo and left a suggestion for it.
slack_sdk/models/blocks/blocks.py
Outdated
| 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
Thanks. Perhaps, I need to send a patch to the original document as well.
There was a problem hiding this comment.
@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 👍🏻
There was a problem hiding this comment.
Fixed a a text object on https://api.slack.com/reference/block-kit/blocks#input_fields

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
xin each of the[ ])/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
xin each[ ])python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.