Skip to content

Commit

Permalink
fix: add accurate type hints to HistoryIterator (#2340)
Browse files Browse the repository at this point in the history
* add types

Signed-off-by: Honza Javorek <[email protected]>

* style(pre-commit): auto fixes from pre-commit.com hooks

---------

Signed-off-by: Honza Javorek <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
honzajavorek and pre-commit-ci[bot] authored Jan 30, 2024
1 parent 7f9dec2 commit 73ef733
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions discord/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ async def next(self) -> Message:
except asyncio.QueueEmpty:
raise NoMoreItems()

def _get_retrieve(self):
def _get_retrieve(self) -> bool:
l = self.limit
if l is None or l > 100:
r = 100
Expand Down Expand Up @@ -366,11 +366,13 @@ async def fill_messages(self):
self.state.create_message(channel=channel, data=element)
)

async def _retrieve_messages(self, retrieve) -> list[Message]:
async def _retrieve_messages(self, retrieve: int) -> list[MessagePayload]:
"""Retrieve messages and update next parameters."""
raise NotImplementedError

async def _retrieve_messages_before_strategy(self, retrieve):
async def _retrieve_messages_before_strategy(
self, retrieve: int
) -> list[MessagePayload]:
"""Retrieve messages using before parameter."""
before = self.before.id if self.before else None
data: list[MessagePayload] = await self.logs_from(
Expand All @@ -382,7 +384,9 @@ async def _retrieve_messages_before_strategy(self, retrieve):
self.before = Object(id=int(data[-1]["id"]))
return data

async def _retrieve_messages_after_strategy(self, retrieve):
async def _retrieve_messages_after_strategy(
self, retrieve: int
) -> list[MessagePayload]:
"""Retrieve messages using after parameter."""
after = self.after.id if self.after else None
data: list[MessagePayload] = await self.logs_from(
Expand All @@ -394,7 +398,9 @@ async def _retrieve_messages_after_strategy(self, retrieve):
self.after = Object(id=int(data[0]["id"]))
return data

async def _retrieve_messages_around_strategy(self, retrieve):
async def _retrieve_messages_around_strategy(
self, retrieve: int
) -> list[MessagePayload]:
"""Retrieve messages using around parameter."""
if self.around:
around = self.around.id if self.around else None
Expand Down

0 comments on commit 73ef733

Please sign in to comment.