-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix some issues with test, update record, and rework realtime_updates example #6
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.
Thank you for contributing! I have one remark which I'd like you to address before I merge this.
src/pocketbase/services/record.py
Outdated
else: | ||
return await self._pb.realtime.subscribe(self._collection, callback, options) | ||
# No record ID provided, handle the case explicitly (e.g., raise an error) | ||
raise ValueError("Invalid record_id: None") |
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.
I see your motivation for this change is "I modified the subscribe function in record.py to be more faithful to the Pocketbase documentation". I think that is invalid in this case: I do not like the magic "*" character meaning something in a function argument but I do think that making it value None
is sufficient. Unlike Javascript we have a little bit more typing support. I'd ask you to either revert this change or split the subscribe function to a subscribe
and a subscribe_all
function or something.
I understand your point about the "*" character being non-standard and potentially confusing, especially given the stronger typing support in Python compared to Javascript. While my initial goal was to align the function with the Pocketbase documentation, I agree that clarity and maintainability are important. Based on your suggestion, I'll split the subscribe function into two separate functions: Thanks for your feedback |
I'll merge this as soon as the pipeline passes, seems you forgot to run the ruff formatter after your last change 😃 |
My Bad, totally forgot 🫠. This time it will work! |
Thank you @matthieuEv! In the future your PRs should automatically run the checks without me needing to approve them, allowing you to iterate a bit faster. I've also added a |
That sounds perfect to me. I'll be sure to use the bash script for local testing, it will help a lot, thanks! |
Checklist
Description of Changes
I have reworked the
realtime_updates.py
example which was giving an error:httpx.ConnectError: All connection attempts failed
and added an exception handling system.I fixed a bug in
test_admin
where the functiondef test_login(admin_client: PocketBase, admin: tuple[str, str])
was not inasync
and therefore returned an error when testing with pytest.I modified the
subscribe
function inrecord.py
to be more faithful to the Pocketbase documentation:record_id
is empty, an error is returned."*"
, then the subscription is made on all records in the collection.record_id
, then the subscription is made on that particular record.Related Issues
None