Return error when paging with cursor method while using sample #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When sampling records from OpenAlex you must use basic paging instead of cursor paging (see the OpenAlex docs).
Currently pyalex has cursor paging as the default method. If you combine
sample
withpaginate
it will present the first page and then silently stop paging, without any error. For example, the following test fails:Pyalex will choose the default
cursor
method, and only return the first page. So the left side of the assert statement will be 25.In this pull request I make pyalex raise a
ValueError
when trying to use cursor pagination with sampling. If you want, I can also change it so that the default method for pagination becomespage
in case of sampling, but I thought it was better to be explicit and just let the user know that their combination is not allowed. Let me know if you think differently and I'll update my changes!