Skip to content

Commit

Permalink
Move around remaining int as bool subclasses int
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Feb 1, 2024
1 parent 3e9c27d commit c75c442
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions novus/api/api_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ async def __aiter__(self) -> AsyncGenerator[T, Any]:
while self._remaining:

# Work out what our request limit is
if isinstance(self._remaining, int):
limit = min(self.method_limit, self._remaining)
else:
if self._remaining is True:
limit = self.method_limit
else:
# is an int
limit = min(self.method_limit, self._remaining)

# Get items from the api
items: list[T] = await self.method(
Expand All @@ -84,7 +85,7 @@ async def __aiter__(self) -> AsyncGenerator[T, Any]:
# Yield our just-given items
for i in items:
yield i
if isinstance(self._remaining, int):
if self._remaining is not True:
self._remaining -= 1

# Break out of this if we didn't get the right number of messages
Expand Down

0 comments on commit c75c442

Please sign in to comment.