diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-01-14 04:39:33 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 9009fa39dd5d6c4101e2f339182285d23abf0cf3 (patch) | |
tree | 961c64296c614452510cc11f354deb78eec8c451 /typings/slack_api.pyi | |
parent | 81e98c8b7049fd08886ba7099bba02130b6026a2 (diff) | |
download | wee-slack-9009fa39dd5d6c4101e2f339182285d23abf0cf3.tar.gz |
Fix typing for fetch info
Diffstat (limited to 'typings/slack_api.pyi')
-rw-r--r-- | typings/slack_api.pyi | 175 |
1 files changed, 130 insertions, 45 deletions
diff --git a/typings/slack_api.pyi b/typings/slack_api.pyi index 1f966e5..4842571 100644 --- a/typings/slack_api.pyi +++ b/typings/slack_api.pyi @@ -1,73 +1,158 @@ -from typing import TypedDict +from __future__ import annotations +from typing import List, Literal, TypedDict, final + +@final class SlackTopic(TypedDict): value: str creator: str last_set: int +@final class SlackPurpose(TypedDict): value: str creator: str last_set: int -class SlackConversationCommon(TypedDict): - id: str +@final +class SlackBlockElement(TypedDict): + type: str + text: str + +@final +class SlackBlockElementParent(TypedDict): + type: str + elements: List[SlackBlockElement] + +@final +class SlackBlock(TypedDict): + type: str + block_id: str + elements: List[SlackBlockElementParent] -class SlackConversationCommonNotIm(SlackConversationCommon): +@final +class SlackLatest(TypedDict): + client_msg_id: str + type: str + text: str + user: str + ts: str + blocks: List[SlackBlock] + team: str + +class SlackConversationInfoCommon(TypedDict): + id: str created: int - creator: str is_archived: bool + is_org_shared: bool + context_team_id: str + last_read: str + +class SlackConversationInfoCommonNotIm(SlackConversationInfoCommon): + name: str is_channel: bool - is_ext_shared: bool - is_general: bool is_group: bool - is_im: bool - is_member: bool - is_mpim: bool - is_org_shared: bool - is_pending_ext_shared: bool - is_private: bool - is_shared: bool + is_im: Literal[False] + is_general: bool + unlinked: int name_normalized: str - name: str - num_members: int + is_shared: bool + is_pending_ext_shared: bool + pending_shared: List # pyright: ignore [reportMissingTypeArgument] parent_conversation: None - pending_connected_team_ids: list - pending_shared: list - previous_names: list[str] - purpose: SlackPurpose - shared_team_ids: list[str] + creator: str + is_ext_shared: bool + shared_team_ids: List[str] + pending_connected_team_ids: List # pyright: ignore [reportMissingTypeArgument] + is_member: bool topic: SlackTopic - unlinked: int + purpose: SlackPurpose -class SlackConversationPublic(SlackConversationCommonNotIm): - num_members: int - previous_names: list[str] +@final +class SlackConversationInfoPublic(SlackConversationInfoCommonNotIm): + is_mpim: Literal[False] + is_private: Literal[False] + previous_names: List[str] # TODO: Check if private and mpim has this -class SlackConversationPrivate(SlackConversationCommonNotIm): - num_members: int +@final +class SlackConversationInfoPrivate(SlackConversationInfoCommonNotIm): + is_mpim: Literal[False] + is_private: Literal[True] + is_open: bool -class SlackConversationMpim(SlackConversationCommonNotIm): - num_members: int +@final +class SlackConversationInfoMpim(SlackConversationInfoCommonNotIm): + is_mpim: Literal[True] + is_private: Literal[True] + is_open: bool -class SlackConversationGroup(SlackConversationCommonNotIm): +@final +class SlackConversationInfoIm(SlackConversationInfoCommon): + is_im: Literal[True] + user: str + latest: SlackLatest + unread_count: int + unread_count_display: int is_open: bool - last_read: str priority: int -class SlackConversationIm(SlackConversationCommon): - created: int - is_archived: bool - is_im: bool - is_org_shared: bool - is_user_deleted: bool - priority: int - user: str +SlackConversationInfoNotIm = ( + SlackConversationInfoPublic + | SlackConversationInfoPrivate + | SlackConversationInfoMpim +) +SlackConversationInfo = SlackConversationInfoNotIm | SlackConversationInfoIm -SlackConversationNotIm = ( - SlackConversationPublic - | SlackConversationPrivate - | SlackConversationMpim - | SlackConversationGroup +@final +class SlackConversationInfoErrorResponse(TypedDict): + ok: Literal[False] + error: str + +@final +class SlackConversationInfoPublicSuccessResponse(TypedDict): + ok: Literal[True] + channel: SlackConversationInfoPublic + +@final +class SlackConversationInfoPrivateSuccessResponse(TypedDict): + ok: Literal[True] + channel: SlackConversationInfoPrivate + +@final +class SlackConversationInfoMpimSuccessResponse(TypedDict): + ok: Literal[True] + channel: SlackConversationInfoMpim + +@final +class SlackConversationInfoImSuccessResponse(TypedDict): + ok: Literal[True] + channel: SlackConversationInfoIm + +@final +class SlackConversationInfoNotImSuccessResponse(TypedDict): + ok: Literal[True] + channel: SlackConversationInfoNotIm + +@final +class SlackConversationInfoSuccessResponse(TypedDict): + ok: Literal[True] + channel: SlackConversationInfo + +SlackConversationInfoPublicResponse = ( + SlackConversationInfoPublicSuccessResponse | SlackConversationInfoErrorResponse +) +SlackConversationInfoPrivateResponse = ( + SlackConversationInfoPrivateSuccessResponse | SlackConversationInfoErrorResponse +) +SlackConversationInfoMpimResponse = ( + SlackConversationInfoMpimSuccessResponse | SlackConversationInfoErrorResponse +) +SlackConversationInfoImResponse = ( + SlackConversationInfoImSuccessResponse | SlackConversationInfoErrorResponse +) +SlackConversationInfoNotImResponse = ( + SlackConversationInfoNotImSuccessResponse | SlackConversationInfoErrorResponse +) +SlackConversationInfoResponse = ( + SlackConversationInfoSuccessResponse | SlackConversationInfoErrorResponse ) -SlackConversationInfo = SlackConversationNotIm | SlackConversationIm |