Skip to content

Remove custom AsyncIterators subclasses to use Generators #113

@DA-344

Description

@DA-344

Summary

Remove AsyncIterators subclasses accross the lib to start using yield item.

What is the feature request for?

The core library

The Problem

Currently, the library has to mantain a bunch of custom AsyncIterator subclasses used for paginated endpoints, such as Messageable.pins, Guild.bans, etc.

The Ideal Solution

This should change to be typed as (typing or collections.abc).AsyncIterator[YieldType], be converted into async def functions, and simply yield the items.

This would also remove everything related to .flatten so it is better used as l = [i async for i in asynciterator].

An example from Guild.bans:

async def bans(self, params) -> AsyncIterator[Ban]:
    # process stuff

    for result in ...:  # converted mapping of bans for example
        yield result

The Current Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions