Skip to content

Async tutorial#645

Merged
tobixen merged 6 commits intomasterfrom
async-tutorial
Mar 19, 2026
Merged

Async tutorial#645
tobixen merged 6 commits intomasterfrom
async-tutorial

Conversation

@tobixen
Copy link
Member

@tobixen tobixen commented Mar 19, 2026

New async tutorial + some bugfixes on the async API

@tobixen tobixen force-pushed the async-tutorial branch 2 times, most recently from a364e98 to 49b3e8e Compare March 19, 2026 14:58
tobixen and others added 6 commits March 19, 2026 18:14
The async factory functions already existed in caldav.async_davclient
but were not re-exported from caldav.aio, leaving no parity with the
sync API where caldav.get_calendars / caldav.get_calendar are available.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… invite methods

Similar to the save()/complete() fix in e819a3a, these methods called
self.save() or self.parent.get_object_by_uid() without awaiting, so in
async mode the returned coroutines were silently discarded.

Changes:
- uncomplete(): delegate to new _async_uncomplete() when is_async_client
- set_relation(): refactor uid/other resolution to share between sync and
  async paths; delegate to new _async_set_relation() when is_async_client;
  extract _add_relation_to_ical() helper to avoid duplicating ical logic
- get_relatives(): extract _parse_relatives_from_ical() helper (pure, no I/O)
  to avoid duplicating ical-parsing logic; delegate to new
  _async_get_relatives() when is_async_client
- _reply_to_invite_request() / accept_invite() / decline_invite() /
  tentatively_accept_invite(): raise NotImplementedError for async clients
  (the entire invite reply flow uses load/save/add_event/schedule_outbox
  which all require async-aware wiring not yet implemented)

Tests: add TestAsyncCalendarObjectResource with 6 unit tests that verify
each fixed method returns a coroutine for async clients and that awaiting
it produces the expected side-effects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…thout await

_async_add_object_finish called _handle_reverse_relations(fix=True), which
internally called self.get_relatives() — returning a coroutine in async mode
instead of the dict, causing TypeError: 'coroutine' object is not iterable.

Added _async_set_reverse_relation, _async_verify_reverse_relation, and
_async_handle_reverse_relations; updated _async_add_object_finish to await
the new async variant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add docs/source/async_tutorial.rst, a step-by-step async tutorial that
mirrors the existing sync tutorial.rst.  Covers the same topics (creating
calendars, accessing calendars, creating events, searching, investigating
events, modifying events, tasks) plus a "Parallel Operations" section
demonstrating asyncio.gather().

Also update tutorial.rst to link to the new async tutorial instead of
saying "will come soon", and add async_tutorial to the docs index.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tives

Documents the structural problem with the current is_async_client branching
approach: silent coroutine discard, incorrect type annotations, growing
method-pair count, and which methods still lack async support.

Also covers alternative designs (separate async classes, full sans-IO) and
practical recommendations (mandatory coroutine tests, type overloads, lint rule).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a "Testing server compatibility" section to configfile.rst
explaining how to find, install, and run caldav-server-tester, and
how to use its output to populate the features key in calendar.conf.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tobixen tobixen merged commit e1a11f6 into master Mar 19, 2026
9 checks passed
@tobixen tobixen deleted the async-tutorial branch March 19, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant