-
Notifications
You must be signed in to change notification settings - Fork 144
refactor: Improve webhook typing. #1193
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
Open
elenakrittik
wants to merge
9
commits into
DisnakeDev:master
Choose a base branch
from
elenakrittik:refactor/wh/typing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a67fd61
refactor: Improve webhook typing.
elenakrittik 168d93f
fix: remove dangerous type ignore
elenakrittik 245e65f
fix: add future import
elenakrittik dc3dbdc
docs: add chanelog entry
elenakrittik 8860280
misc: Move what's possible into a TYPE_CHECKING block, change imports…
elenakrittik c66ff87
docs: Fix .send descriptions
elenakrittik ec9a610
misc: move .send into a TYPE_CHECKING block
elenakrittik 4d0d103
Merge branch 'master' into refactor/wh/typing
elenakrittik 380cf52
Merge branch 'master' into refactor/wh/typing
onerandomusername File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Improve type annotations for :attr:`Interaction.followup`\'s ``.send`` method. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# SPDX-License-Identifier: MIT | ||
|
||
from __future__ import annotations | ||
|
||
from collections.abc import Sequence | ||
from typing import List, Optional | ||
|
||
from disnake.abc import Snowflake | ||
from disnake.embeds import Embed | ||
from disnake.file import File | ||
from disnake.flags import MessageFlags | ||
from disnake.mentions import AllowedMentions | ||
from disnake.ui.action_row import Components, MessageUIComponent | ||
from disnake.ui.view import View | ||
from disnake.utils import MISSING | ||
from disnake.webhook.async_ import Webhook, WebhookMessage | ||
elenakrittik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
__all__ = ("InteractionFollowupWebhook",) | ||
|
||
|
||
class InteractionFollowupWebhook(Webhook): | ||
"""A 1:1 copy of :class:`Webhook` meant for :attr:`Interaction.followup`\\'s annotations.""" | ||
|
||
async def send( | ||
self, | ||
content: Optional[str] = MISSING, | ||
*, | ||
tts: bool = MISSING, | ||
ephemeral: bool = MISSING, | ||
suppress_embeds: bool = MISSING, | ||
flags: MessageFlags = MISSING, | ||
file: File = MISSING, | ||
files: List[File] = MISSING, | ||
embed: Embed = MISSING, | ||
embeds: List[Embed] = MISSING, | ||
allowed_mentions: AllowedMentions = MISSING, | ||
view: View = MISSING, | ||
components: Components[MessageUIComponent] = MISSING, | ||
thread: Snowflake = MISSING, | ||
thread_name: str = MISSING, | ||
applied_tags: Sequence[Snowflake] = MISSING, | ||
delete_after: float = MISSING, | ||
) -> WebhookMessage: | ||
"""|coro| | ||
Sends a message using the webhook. | ||
This is the same as :meth:`Webhook.send` but with type hints changed. Namely, | ||
the return type is :class:`WebhookMessage` instead of :class:`Message` because | ||
``wait=True`` for interaction webhooks, and ``username`` and ``avatar_url`` are | ||
not supported. | ||
Returns | ||
------- | ||
:class:`WebhookMessage` | ||
The message that was sent. | ||
""" | ||
return await super().send( | ||
content=content, | ||
tts=tts, | ||
ephemeral=ephemeral, | ||
embeds=embeds, | ||
embed=embed, | ||
file=file, | ||
files=files, | ||
view=view, | ||
components=components, | ||
allowed_mentions=allowed_mentions, | ||
thread=thread, | ||
thread_name=thread_name, | ||
applied_tags=applied_tags, | ||
delete_after=delete_after, | ||
suppress_embeds=suppress_embeds, | ||
flags=flags, | ||
wait=True, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.