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

TypeError on automated pagination #341

Open
FedericoCeratto opened this issue May 6, 2023 · 2 comments
Open

TypeError on automated pagination #341

FedericoCeratto opened this issue May 6, 2023 · 2 comments

Comments

@FedericoCeratto
Copy link

Hello and thanks for developing this library.

mastodon.fetch_next called on an empty list of toots leads to:

  File "/usr/lib/python3/dist-packages/mastodon/utility.py", line 206, in fetch_next
    method = params['_pagination_method']
             ~~~~~~^^^^^^^^^^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str

Steps to reproduce:

toots = mastodon.timeline()
while True:
    toots = mastodon.fetch_next(toots)

It seems that fetch_next returns an empty list after 800 toots and breaks the next run. Perhaps the library could provide an iterator that terminates at the end instead?

Thanks!

@halcy
Copy link
Owner

halcy commented May 11, 2023

yeah, that sounds like a really good idea, actually.

Workshopping this in my head, so I'm wondering, what do (or others) you think would make more sense:

  • An iterator that iterates pages?
  • An iterator that iterates post and fetches next page as needed?
  • Both?

@gglanzani
Copy link

Late to the party, but IMHO, option 2 (An iterator that iterates post and fetches next page as needed?) seems better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants