Skip to content

fix: async support for save() recurrence handling and complete()#644

Merged
tobixen merged 2 commits intomasterfrom
fix-async-save
Mar 19, 2026
Merged

fix: async support for save() recurrence handling and complete()#644
tobixen merged 2 commits intomasterfrom
fix-async-save

Conversation

@tobixen
Copy link
Copy Markdown
Member

@tobixen tobixen commented Mar 18, 2026

(also related to #642)

save() called get_self() (a sync helper that invokes parent collection
methods) even for async clients, but those methods return unawaited
coroutines in async mode, causing AttributeError when accessing
.icalendar_instance on the coroutine.

Fix by delegating to _async_save() at the top of save() when
is_async_client is True, with an async get_self() that properly awaits
the parent collection methods.

Similarly, complete() returned None for async clients (self.save()
returned a coroutine that was ignored), so "await task.complete()"
raised TypeError: 'NoneType' object can't be awaited. Fix by adding
_async_complete() that awaits self.save().

To avoid duplicating the icalendar manipulation logic, extract three
shared helpers:

  • _validate_save_constraints(): raises on no_overwrite/no_create violations
  • _incorporate_recurrence_into_parent(): merges a recurrence instance
    into the parent event's icalendar_instance (pure, no I/O)
  • _maybe_increment_sequence(): increments SEQUENCE if present

The now-redundant _async_save_final() is removed.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

tobixen and others added 2 commits March 19, 2026 00:08
save() called get_self() (a sync helper that invokes parent collection
methods) even for async clients, but those methods return unawaited
coroutines in async mode, causing AttributeError when accessing
.icalendar_instance on the coroutine.

Fix by delegating to _async_save() at the top of save() when
is_async_client is True, with an async get_self() that properly awaits
the parent collection methods.

Similarly, complete() returned None for async clients (self.save()
returned a coroutine that was ignored), so "await task.complete()"
raised TypeError: 'NoneType' object can't be awaited.  Fix by adding
_async_complete() that awaits self.save().

To avoid duplicating the icalendar manipulation logic, extract three
shared helpers:
- _validate_save_constraints(): raises on no_overwrite/no_create violations
- _incorporate_recurrence_into_parent(): merges a recurrence instance
  into the parent event's icalendar_instance (pure, no I/O)
- _maybe_increment_sequence(): increments SEQUENCE if present

The now-redundant _async_save_final() is removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tobixen tobixen merged commit 376c580 into master Mar 19, 2026
9 checks passed
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