Skip to content

Commit 7892a9b

Browse files
authored
Fix #1178 text type hint in LinkButtonElement does not accept PlainTextObject/dict (#1183)
1 parent 1778647 commit 7892a9b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

slack_sdk/models/blocks/block_elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class LinkButtonElement(ButtonElement):
325325
def __init__(
326326
self,
327327
*,
328-
text: str,
328+
text: Union[str, dict, PlainTextObject],
329329
url: str,
330330
action_id: Optional[str] = None,
331331
style: Optional[str] = None,

tests/slack_sdk/models/test_elements.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
Option,
2727
InputInteractiveElement,
2828
InteractiveElement,
29+
PlainTextObject,
2930
)
3031
from . import STRING_3001_CHARS, STRING_301_CHARS
3132

@@ -209,6 +210,23 @@ def test_json(self):
209210
button.to_dict(),
210211
)
211212

213+
# https://github.com/slackapi/python-slack-sdk/issues/1178
214+
def test_text_patterns_issue_1178(self):
215+
button = LinkButtonElement(
216+
action_id="test",
217+
text=PlainTextObject(text="button text"),
218+
url="http://slack.com",
219+
)
220+
self.assertDictEqual(
221+
{
222+
"text": {"text": "button text", "type": "plain_text"},
223+
"url": "http://slack.com",
224+
"type": "button",
225+
"action_id": button.action_id,
226+
},
227+
button.to_dict(),
228+
)
229+
212230
def test_url_length(self):
213231
with self.assertRaises(SlackObjectFormationError):
214232
LinkButtonElement(text="Button", url=STRING_3001_CHARS).to_dict()

0 commit comments

Comments
 (0)