-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
♻️ ref(slack): fix slack webhook actions typing #77322
Conversation
webhook_client = WebhookClient(response_url) | ||
try: | ||
webhook_client.send( | ||
blocks=json_blocks, | ||
blocks=response.get("blocks"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need to do this, originally that orjson line only converted from single quotes to double quotes (i am assume this was because in pre-slack_sdk world, we needed to. the slack_sdk handles this for us, i verified this with my local setup
action_data = slack_request.data.get("actions") | ||
if action_data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need this since we have ga'ed blockkit for months now and won't be dealing with non-blockkit interactions.
@@ -421,7 +423,7 @@ def __init__( | |||
event: Event | GroupEvent | None = None, | |||
tags: set[str] | None = None, | |||
identity: RpcIdentity | None = None, | |||
actions: Sequence[MessageAction] | None = None, | |||
actions: Sequence[MessageAction | BlockKitMessageAction] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between MessageAction
and BlockKitMessageAction
? should we always be using one over the other if we don't support non-block kit anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we should delete MessageAction
, but i saw some places in our logic where we create a MessageAction
payload to send to slack, so i want to slowly remove it so make sure we don't break changes since ff this is hard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as I mentioned here it seems like BlockKitMessageAction
ought to extend MessageAction
(assuming we need both).
The "TODO" comment on MessageAction
suggests that its bottom four attributes (including block_id
, which is confusing) ought to belong to some other subclass. But I agree with delaying that sort of refactoring for later.
I'm okay with using MessageAction | BlockKitMessageAction
for type hints temporarily, but would consider changing BlockKitMessageAction
to extend MessageAction
instead.
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #77322 +/- ##
==========================================
+ Coverage 78.12% 78.14% +0.01%
==========================================
Files 6996 6967 -29
Lines 310293 309641 -652
Branches 50765 50658 -107
==========================================
- Hits 242415 241963 -452
- Misses 56156 61259 +5103
+ Partials 11722 6419 -5303 |
28bfc32
to
f6ca079
Compare
if isinstance(error.detail, dict): | ||
text = list(*error.detail.values())[0] | ||
else: | ||
text = str(error.detail[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the type definition for error.detail
allows lists and/or dictionaries to be nested recursively. It might be more correct to do something like the helper function I sketched out here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i yoinked that helper into this pr 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
fixing the typing for Slack webhook actions. i also removed some old non slack blockkit logic since we have GA'ed for a while and won't have to deal with interactions with the old messages.
fixing the typing for Slack webhook actions. i also removed some old non slack blockkit logic since we have GA'ed for a while and won't have to deal with interactions with the old messages.
fixing the typing for Slack webhook actions. i also removed some old non slack blockkit logic since we have GA'ed for a while and won't have to deal with interactions with the old messages.