githubkit icon indicating copy to clipboard operation
githubkit copied to clipboard

Feature: pagination with `link` header

Open brandonchinn178 opened this issue 9 months ago • 5 comments

I would expect the following to work:

github.paginate(github.rest.orgs.list_webhook_deliveries, hook_org, hook_id)

But currently, those values are passed to page/per_page. It seems like the only way to pass positional args is by manually specifying page/per_page/map_func?

brandonchinn178 avatar Mar 12 '25 17:03 brandonchinn178

You can pass them with kwargs:

github.paginate(github.rest.orgs.list_webhook_deliveries, org=hook_org, hook_id=hook_id)

yanyongyu avatar Mar 13 '25 08:03 yanyongyu

It seem this list_webhook_deliveries api uses cursor/per_page pagination. Currently, githubkit's paginator is based on page/per_page. May be you should handle the pagination yourself now.

yanyongyu avatar Mar 13 '25 08:03 yanyongyu

I know I can pass as kwargs, but the signature has *args: P.args, so I would expect positional arguments to work too. If they're not intended to work, it should either be removed or documented how to use them.

It seem this list_webhook_deliveries api uses cursor/per_page pagination. Currently, githubkit's paginator is based on page/per_page. May be you should handle the pagination yourself now.

Noted. Can work around for now. Would it be possible to add support for this?

brandonchinn178 avatar Mar 13 '25 14:03 brandonchinn178

After taking a look at the latest docs, GitHub can now uses the link header to do pagination. Octokit also supports this now (ref).

I will try to implement this.

yanyongyu avatar Mar 13 '25 15:03 yanyongyu

Broke out positional args into a separate issue.

Also, should the type of github.paginate be updated to check that the function as page/per_page arguments? Otherwise, it'll fail at runtime.

Perhaps use Protocol instead of ParamSpec?

brandonchinn178 avatar Mar 13 '25 16:03 brandonchinn178