Skip to content
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

Return new instance in Poll.end to avoid inconsistencies #10056

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions discord/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def get_answer(

return self._answers.get(id)

async def end(self) -> Self:
async def end(self) -> Poll:
Copy link
Contributor

@DA-344 DA-344 Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is typed likeSelf for subclasses

"""|coro|

Ends the poll.
Expand All @@ -568,6 +568,5 @@ async def end(self) -> Self:
if not self._message or not self._state: # Make type checker happy
raise ClientException('This poll has no attached message.')

self._message = await self._message.end_poll()

return self
message = await self._message.end_poll()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

._message still needs to be set, plus, you can simply do self._update(message) to update the data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I went with this way intentionally because I wasn’t sure if the update should even be in-place. I’ll change it to make sure everything is done to the current instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could change the _update behaviour to update the current poll vote count and such, though

return message.poll