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

Remove confusing warning messages #1030 #1032

Merged
merged 2 commits into from Jun 10, 2021
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
19 changes: 16 additions & 3 deletions slack_sdk/models/blocks/block_elements.py
Expand Up @@ -149,10 +149,17 @@ def __init__(
subtype: Optional[str] = None,
**others: dict,
):
"""An interactive block element.

We generally recommend using the concrete subclasses for better supports of available properties.
"""
if subtype:
self._subtype_warning()
super().__init__(type=type or subtype)
show_unknown_key_warning(self, others)

# Note that we don't intentionally have show_unknown_key_warning for the unknown key warnings here.
# It's fine to pass any kwargs to the held dict here although the class does not do any validation.
# show_unknown_key_warning(self, others)

self.action_id = action_id

Expand Down Expand Up @@ -190,11 +197,17 @@ def __init__(
confirm: Optional[Union[dict, ConfirmObject]] = None,
**others: dict,
):
"""InteractiveElement that is usable in input blocks"""
"""InteractiveElement that is usable in input blocks

We generally recommend using the concrete subclasses for better supports of available properties.
"""
if subtype:
self._subtype_warning()
super().__init__(action_id=action_id, type=type or subtype)
show_unknown_key_warning(self, others)

# Note that we don't intentionally have show_unknown_key_warning for the unknown key warnings here.
# It's fine to pass any kwargs to the held dict here although the class does not do any validation.
# show_unknown_key_warning(self, others)

self.placeholder = TextObject.parse(placeholder)
self.confirm = ConfirmObject.parse(confirm)
Expand Down
22 changes: 22 additions & 0 deletions tests/slack_sdk/models/test_elements.py
Expand Up @@ -23,6 +23,8 @@
ChannelSelectElement,
ConfirmObject,
Option,
InputInteractiveElement,
InteractiveElement,
)
from . import STRING_3001_CHARS, STRING_301_CHARS

Expand All @@ -32,6 +34,26 @@
# -------------------------------------------------


class InteractiveElementTests(unittest.TestCase):
def test_with_interactive_element(self):
input = {
"type": "plain_text_input",
"action_id": "plain_input",
"placeholder": {"type": "plain_text", "text": "Enter some plain text"},
}
# Any properties should not be lost
self.assertDictEqual(input, InteractiveElement(**input).to_dict())

def test_with_input_interactive_element(self):
input = {
"type": "plain_text_input",
"action_id": "plain_input",
"placeholder": {"type": "plain_text", "text": "Enter some plain text"},
}
# Any properties should not be lost
self.assertDictEqual(input, InputInteractiveElement(**input).to_dict())


class InteractiveElementTests(unittest.TestCase):
def test_action_id(self):
with self.assertRaises(SlackObjectFormationError):
Expand Down