-
Notifications
You must be signed in to change notification settings - Fork 140
feat(Webhook)!: New classes PartialWebhook & PartialSyncWebhook #878
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
base: master
Are you sure you want to change the base?
Conversation
@Snipy7374 would you please resolve conflicts? |
Oke |
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.
A few documentation nitpicks (mostly).
Also, i think it would make a lot more sense if [Sync]Webhook
inherited from Partial[Sync]Webhook
than the other way around. If maintainers/users are fine with a little more breakage, i'd do it.
@@ -0,0 +1 @@ | |||
Documents ``TypeError`` raised on invalid session passed for :meth:`PartialSyncWebhook.from_url`. |
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.
Documents ``TypeError`` raised on invalid session passed for :meth:`PartialSyncWebhook.from_url`. | |
Document ``TypeError`` raised on invalid session passed for :meth:`PartialSyncWebhook.from_url`. |
@@ -0,0 +1 @@ | |||
Migrate ``fetch`` methods of :class:`Webhook` and :class:`SyncWebhook` to :class:`PartialWebhook` and :class:`PartialSyncWebhook`. |
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.
Migrate ``fetch`` methods of :class:`Webhook` and :class:`SyncWebhook` to :class:`PartialWebhook` and :class:`PartialSyncWebhook`. | |
Move ``fetch`` methods of :class:`Webhook` and :class:`SyncWebhook` to :class:`PartialWebhook` and :class:`PartialSyncWebhook`. |
Adds :class:`PartialWebhook` and :class:`PartialSyncWebhook` to represent partial webhook objects, in addition the :meth:`from_url` | ||
and :meth:`partial` methods will now returns a partial webhook object that could be either a :class:`PartialWebhook` or :class:`PartialSyncWebhook`. |
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.
Adds :class:`PartialWebhook` and :class:`PartialSyncWebhook` to represent partial webhook objects, in addition the :meth:`from_url` | |
and :meth:`partial` methods will now returns a partial webhook object that could be either a :class:`PartialWebhook` or :class:`PartialSyncWebhook`. | |
Add :class:`PartialWebhook` and :class:`PartialSyncWebhook` to represent partial webhook objects, in addition the :meth:`from_url` | |
and :meth:`partial` methods will now return a partial webhook object that could be either a :class:`PartialWebhook` or :class:`PartialSyncWebhook`. |
In addition, i think this should be split into two separate changelog entries.
@classmethod | ||
def partial( | ||
cls, id: int, token: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None | ||
) -> Webhook: | ||
"""Creates a partial :class:`Webhook`. | ||
self, |
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.
self
appears to be unused, so i believe this should be at least made a @staticmethod
. More generally, i think this should also be moved to PartialWebhook
(in that case it should remain a @classmethod
)
@classmethod | ||
def from_url( | ||
cls, url: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None | ||
) -> Webhook: | ||
"""Creates a partial :class:`Webhook` from a webhook URL. | ||
self, url: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None | ||
) -> PartialWebhook: |
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.
Same as with Webhook.partial
, this should at least be made a @staticmethod
and ideally moved to PartialWebhook
itself.
session: aiohttp.ClientSession, | ||
bot_token: Optional[str] = None, | ||
) -> PartialWebhook: | ||
"""Creates a :class:`PartialWebhook`. |
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.
"""Creates a :class:`PartialWebhook`. | |
"""Create a :class:`PartialWebhook`. |
@@ -1140,17 +1148,19 @@ def partial( | |||
"token": token, | |||
} | |||
|
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.
Should we do an isinstance(session, aiohttp.Session)
check here to be consistent with SynchWebhook
?
"""Creates a partial :class:`Webhook` from a webhook URL. | ||
self, url: str, *, session: aiohttp.ClientSession, bot_token: Optional[str] = None | ||
) -> PartialWebhook: | ||
"""Creates a :class:`PartialWebhook` from a webhook URL. |
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.
"""Creates a :class:`PartialWebhook` from a webhook URL. | |
"""Create a :class:`PartialWebhook` from a webhook URL. | |
``| |
@@ -1188,7 +1198,7 @@ def from_url( | |||
|
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.
Same again: should we do an isinstance check on session
somewhere here for consistency with SyncWebhook
?
"""Fetches the current PartialSyncWebhook to get a full webhook. | ||
|
||
This could be used to get a full webhook from a partial webhook. |
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.
"""Fetches the current PartialSyncWebhook to get a full webhook. | |
This could be used to get a full webhook from a partial webhook. | |
"""Fetch the full :class:`SyncWebhook` from this partial webhook. |
Summary
Extras:
webhook/async_.py#L964-L971
moved__repr__
andurl
fromWebhook
andSyncWebhook
toBaseWebhook
to reduce code redundancy.webhook/sync.py#L644-L645
document whenSyncWebhook.from_url()
could raise aTypeError
.Checklist
task lint
task pyright