Quantcast
Viewing all articles
Browse latest Browse all 14040

python - Difference of typing with AsyncGenerator or AsyncIterator?

I make creating a discord asynchronous library that is fully typed.I have a method that create objects from a aiohttp get requests such as the following example:

async def get_bans(self):"""|coro|    Fetches all the bans in the guild."""    data = await self._http.get(f"guilds/{self.id}/bans")    for ban_data in data:        yield Ban.from_dict(construct_client_dict(self._client, ban_data))

I was wondering about the return type of this code snippet and whether it should be a AsyncGenerator[Ban, None] or AsyncIterator[Ban, None]. To be honest i have been searching for a bit, and i could find any information that would gave me a clear idea on the subject.


Viewing all articles
Browse latest Browse all 14040

Trending Articles