Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1178 text type hint in LinkButtonElement does not accept PlainTextObject/dict #1183

Merged
merged 1 commit into from Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion slack_sdk/models/blocks/block_elements.py
Expand Up @@ -325,7 +325,7 @@ class LinkButtonElement(ButtonElement):
def __init__(
self,
*,
text: str,
text: Union[str, dict, PlainTextObject],
url: str,
action_id: Optional[str] = None,
style: Optional[str] = None,
Expand Down
18 changes: 18 additions & 0 deletions tests/slack_sdk/models/test_elements.py
Expand Up @@ -26,6 +26,7 @@
Option,
InputInteractiveElement,
InteractiveElement,
PlainTextObject,
)
from . import STRING_3001_CHARS, STRING_301_CHARS

Expand Down Expand Up @@ -209,6 +210,23 @@ def test_json(self):
button.to_dict(),
)

# https://github.com/slackapi/python-slack-sdk/issues/1178
def test_text_patterns_issue_1178(self):
button = LinkButtonElement(
action_id="test",
text=PlainTextObject(text="button text"),
url="http://slack.com",
)
self.assertDictEqual(
{
"text": {"text": "button text", "type": "plain_text"},
"url": "http://slack.com",
"type": "button",
"action_id": button.action_id,
},
button.to_dict(),
)

def test_url_length(self):
with self.assertRaises(SlackObjectFormationError):
LinkButtonElement(text="Button", url=STRING_3001_CHARS).to_dict()
Expand Down