fix: async support for get_object_by_uid (issue #642)#643
Merged
Conversation
get_object_by_uid() called self.search() which, for async clients, returns a coroutine rather than a list. The method then tried to iterate over the coroutine, raising TypeError. Fix by adding _async_get_object_by_uid() that awaits the search, and dispatching to it when is_async_client is True, following the same pattern used by other async-capable methods in the class. The get_todo_by_uid(), get_event_by_uid(), get_journal_by_uid() and the deprecated *_by_uid() aliases are fixed transitively because they all call get_object_by_uid(). Fixes #642 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
get_object_by_uid()(and theget_todo_by_uid,get_event_by_uid,get_journal_by_uidwrappers, plus the deprecatedtodo_by_uid/event_by_uid/journal_by_uidaliases) were broken for async clients.is_async_clientisTrue,Calendar.search()returns a coroutine rather than a list.get_object_by_uid()tried to iterate over the coroutine directly, raisingTypeError: 'coroutine' object is not iterable._async_get_object_by_uid()coroutine whenis_async_clientisTrue, following the same pattern already used by_async_add_object_finish,_async_make_calendar,_async_calendar_delete, etc.Fixes #642
Test plan
TestAsyncGetObjectByUid::test_get_object_by_uid_returns_coroutine_for_async_client— verifies thatget_object_by_uid()returns a coroutine (not a TypeError) for async clientsTestAsyncGetObjectByUid::test_get_object_by_uid_async_returns_correct_object— verifies that awaiting the coroutine returns the correct object