-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Basic pagination support for result sets. #51
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks right! This is really helpful.
Have you run pre-commit run
?
The docstrings don't comply with pydocstyle. Little modifications will fix all the warnings.
How do I run this manually? |
By running the command For more details read the contributing guidelines page in the website. https://ramnes.github.io/notion-sdk-py/contributing/contributing/ |
Okay, added the additional paging endpoints and fixed the pre-commit failures. |
Hang on... Found a bug. |
notion_client/helpers.py
Outdated
def load_next_page(self) -> Any: | ||
"""Must be implemented in subclasses. | ||
|
||
Returns the next page of content or None. | ||
""" | ||
raise ValueError |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks nice 🎉
Hi @jheddings, it would be great if you please add an example to use this new features. |
Can you find a way to make this generic? The |
And yes, as @aahnik said, this needs an example somewhere at the very least, and ideally tests. :) |
Added examples and some documentation... I added a general form of the iterator, but personally I like having the explicit iterators for clarity in the code. It also keeps doors open in the future if there is any need to handle results differently, for example if we use this in the upcoming ORM feature. We can remove if you guys disagree. As for testing, I'll keep looking into it. It's difficult without mocked endpoints, but I'll see what I can do. |
Yeah I'd prefer to keep the code as concise as possible and have only one way to do things, please. :) |
For the tests, I don't think you actually need to call the API nor to mock it, you can just give any function that returns what you expect to receive from an endpoint method. |
It's your world, boss ;) Removed the specific iterator classes and updated docs / examples.
I added a basic test with a mock endpoint. I'm not sure if there is a place to submit the tests for automatic execution, but it is working locally :) |
@@ -0,0 +1,26 @@ | |||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought, may be you can combine all the iterators in 1 file. It feels fairly repetitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is... But the point of the examples are to provide specific, easy to read use cases. Combining all endpoints in a single file makes it harder to pick out the point of each example. I'm happy with the way it is, but of course someone is always free to make further changes.
Tests failed due to codecov upload error codecov/codecov-action#330 |
It looks like the Codecov checks are missing the actions API upload token... |
Codecov Report
@@ Coverage Diff @@
## main #51 +/- ##
===========================================
- Coverage 90.10% 78.94% -11.16%
===========================================
Files 7 7
Lines 192 266 +74
===========================================
+ Hits 173 210 +37
- Misses 19 56 +37
Continue to review full report at Codecov.
|
I just ran checks again and it passed. Looks like Codecov guys fixed it. :) |
Any concerns merging this PR? It's starting to drift from main, so I've pulled the latest into the branch. |
Hey, sorry for the silence; I'm not sure about the API and it's on my to-do list to wrap my head around this but I haven't managed to do it yet. |
No worries... I have created a "higher level" module for the API to avoid cluttering up the core SDK. Check out notional if you are interested. |
You put a great effort there! Let's close this in favor of notional... for now. :P |
It'd be great to see this reopened and merged. |
@patrickwalton Basic pagination support has been implemented a few months ago, and that's shown in the README: https://github.com/ramnes/notion-sdk-py#utility-functions |
Creates an iterator from a database query, which fetches new results as needed.
If this looks like a reasonable approach, I will look into adding support for the other endpoints.