InputBlock returns class Object instead of parsable dict
while using slack_sdk.models.blocks import InputBlock, the inputBlock returns <slack_sdk.InputBlock> instead of InputBlock
Reproducible in:
slack-sdk==3.18.3
The Slack SDK version
slack-sdk==3.18.3
Python runtime version
Python 3.8.10
Steps to reproduce:
print(InputBlock(label=PlainTextObject(text="test"), element=PlainTextInputElement(multiline=True, action_id="plain_text_input_action"))
Expected result:
{'element': {'action_id': 'plain_text_input_action', 'multiline': True, 'type': 'plain_text_input'}, 'label': {'text': 'SSH Key', 'type': 'plain_text'}
Actual result:
<slack_sdk.InputBlock: {'element': {'action_id': 'plain_text_input_action', 'multiline': True, 'type': 'plain_text_input'}, 'label': {'text': 'SSH Key', 'type': 'plain_text'}, 'type': 'input'}>
How do I parse this list?
HI @sharvesh06! Whether this class or another, any time you'd like to take a look at what methods/attributes are available on a given class or instance, you can always reach for the built-in dir function:
thing_to_parse = InputBlock(label=PlainTextObject(text="test"),
element=PlainTextInputElement(multiline=True, action_id="plain_text_input_action"))
dir(thing_to_parse)
From here, we can see that there is a to_dict method. If you invoke it:
thing_to_parse.to_dict()
you will get the output you seem to be looking for.
Let us know if that resolves the issue you're facing!
I think that this question is already answered. Let us close this issue but please feel free to write in if you have follow-up questions.