Commit 3cd8942
feat: make more methods async-aware and refactor
Invite-handling (accept_invite, decline_invite, tentatively_accept_invite)
now returns awaitable coroutines when used in async mode.
SynchronizableCalendarObjectCollection.sync() has also been dealt
with, togheter with `MailBox.get_items()` and `DAVObject.children()`
Also adds design docs:
- docs/design/TODO_SCHEDULE_TAG.md (analysis and implementation plan,
refs #660)
- docs/design/TODO_COMPATIBILITY_HINTS.md (FeatureSet cleanup analysis,
refs #659)
The code logic here is partly human-created, mostly partly AI-created,
certainly under human guideance. The final secision on how to handle
async in 3.x has been carved in stone by a human. Test code is
predominantly AI-created.
The AI-generation involves tedious code duplication work and tedious
routine refactoring, chances for mistakes are bigger when doing it by
hand than by AI. I've been looking through the changes, and I trust
the tests to uncover any errors slipping through.
Some of the (many) commits dealing with this have been squashed
into this commit.
The return type of cached properties should always be an awaitable
coroutine in async mode.
prompt: Please make an async version of the get_items method in
`caldav/collections.py`
followup-prompt: I don't want workarounds in _async_get_items for
async-unaware get_objects_by_sync_token. Fix _async_get_items assuming
get_objects_by_sync_token will be made async-aware.
followup-prompt: Please make an async-version of get_objects_by_sync_token
prompt: Please investigate those failures:
FAILED tests/test_async_integration.py::TestAsyncSchedulingForStalwart (...)
prompt: make an async version of _reply_to_invite_request in
`caldav/calendarobjectresource.py`
prompt: In collection.py and calendarobjectresource.py and
possibly in some of the other files as well, many methods are split up
into a sync version and an async version. Please make appropriate
type-hints for all methods that in async mode will yield a coroutine
rather than an object
Prompt: Let's refactor the async methods where it's possible.
The existing pattern goes like this:
* we have a sync version `foo` or `_foo`
* we have an async version of the same method, `_async_foo`
* `foo` is *most of the time* doing
`if self.is_async_client: return self._async_foo(...)`
I'd like to reduce the amount of duplicated code as well as to split out
the IO-logic as much as possible. As for now, I want to go with this
pattern:
* `foo` should *always* do the
`if self.is_async_client: return self._async_foo(...)`-logic
* `self._async_foo` should never be called upon other places
* Quite many of the methods are doing some preparations, firing off
some other method causing I/O, and then doing some processing of
the data returned from the server. Other methods are more complex,
having mutliple code lines causing I/O.
* For methods containing significant amount of logic (like, two or
more code lines) before doing any IO, the
`if self.is_async_client: return self._async_foo(...)`-logic
should be moved to the last possible point in the method. * For methods
containing significant amount of logic after doing the IO, split the
logic out in a `_post_foo`-method.
(the rules above was later moved to a document and tweaked a bit)
prompt: Apply the rules from `docs/design/ASYNC_DUAL_MODE.md` for the
`def sync` and `def async_sync` in `collection.py`
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 33359d8 commit 3cd8942
14 files changed
Lines changed: 1039 additions & 589 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 74 | | |
91 | | - | |
| 75 | + | |
92 | 76 | | |
93 | 77 | | |
94 | 78 | | |
| |||
98 | 82 | | |
99 | 83 | | |
100 | 84 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 85 | | |
127 | 86 | | |
128 | 87 | | |
| |||
366 | 325 | | |
367 | 326 | | |
368 | 327 | | |
369 | | - | |
| 328 | + | |
370 | 329 | | |
371 | 330 | | |
372 | 331 | | |
| |||
404 | 363 | | |
405 | 364 | | |
406 | 365 | | |
407 | | - | |
| 366 | + | |
408 | 367 | | |
409 | 368 | | |
410 | 369 | | |
| |||
463 | 422 | | |
464 | 423 | | |
465 | 424 | | |
466 | | - | |
| 425 | + | |
467 | 426 | | |
468 | 427 | | |
469 | 428 | | |
| |||
498 | 457 | | |
499 | 458 | | |
500 | 459 | | |
501 | | - | |
| 460 | + | |
502 | 461 | | |
503 | 462 | | |
504 | 463 | | |
| |||
542 | 501 | | |
543 | 502 | | |
544 | 503 | | |
545 | | - | |
| 504 | + | |
546 | 505 | | |
547 | 506 | | |
548 | 507 | | |
| |||
554 | 513 | | |
555 | 514 | | |
556 | 515 | | |
557 | | - | |
| 516 | + | |
558 | 517 | | |
559 | 518 | | |
560 | 519 | | |
| |||
580 | 539 | | |
581 | 540 | | |
582 | 541 | | |
583 | | - | |
| 542 | + | |
584 | 543 | | |
585 | 544 | | |
586 | 545 | | |
| |||
592 | 551 | | |
593 | 552 | | |
594 | 553 | | |
595 | | - | |
| 554 | + | |
596 | 555 | | |
597 | 556 | | |
598 | 557 | | |
| |||
601 | 560 | | |
602 | 561 | | |
603 | 562 | | |
604 | | - | |
| 563 | + | |
605 | 564 | | |
606 | 565 | | |
607 | 566 | | |
| |||
610 | 569 | | |
611 | 570 | | |
612 | 571 | | |
613 | | - | |
| 572 | + | |
614 | 573 | | |
615 | 574 | | |
616 | 575 | | |
| |||
621 | 580 | | |
622 | 581 | | |
623 | 582 | | |
624 | | - | |
| 583 | + | |
625 | 584 | | |
626 | 585 | | |
627 | 586 | | |
| |||
631 | 590 | | |
632 | 591 | | |
633 | 592 | | |
634 | | - | |
| 593 | + | |
635 | 594 | | |
636 | 595 | | |
637 | 596 | | |
| |||
641 | 600 | | |
642 | 601 | | |
643 | 602 | | |
644 | | - | |
| 603 | + | |
645 | 604 | | |
646 | 605 | | |
647 | 606 | | |
| |||
653 | 612 | | |
654 | 613 | | |
655 | 614 | | |
656 | | - | |
| 615 | + | |
657 | 616 | | |
658 | 617 | | |
659 | 618 | | |
| |||
663 | 622 | | |
664 | 623 | | |
665 | 624 | | |
666 | | - | |
| 625 | + | |
667 | 626 | | |
668 | 627 | | |
669 | 628 | | |
| |||
673 | 632 | | |
674 | 633 | | |
675 | 634 | | |
676 | | - | |
| 635 | + | |
677 | 636 | | |
678 | 637 | | |
679 | 638 | | |
| |||
683 | 642 | | |
684 | 643 | | |
685 | 644 | | |
686 | | - | |
| 645 | + | |
687 | 646 | | |
688 | 647 | | |
689 | 648 | | |
| |||
693 | 652 | | |
694 | 653 | | |
695 | 654 | | |
696 | | - | |
| 655 | + | |
697 | 656 | | |
698 | 657 | | |
699 | 658 | | |
| |||
702 | 661 | | |
703 | 662 | | |
704 | 663 | | |
705 | | - | |
| 664 | + | |
706 | 665 | | |
707 | 666 | | |
708 | 667 | | |
| |||
712 | 671 | | |
713 | 672 | | |
714 | 673 | | |
715 | | - | |
| 674 | + | |
716 | 675 | | |
717 | 676 | | |
718 | 677 | | |
719 | 678 | | |
720 | 679 | | |
721 | 680 | | |
722 | 681 | | |
723 | | - | |
| 682 | + | |
724 | 683 | | |
725 | 684 | | |
726 | 685 | | |
| |||
729 | 688 | | |
730 | 689 | | |
731 | 690 | | |
732 | | - | |
| 691 | + | |
733 | 692 | | |
734 | 693 | | |
735 | 694 | | |
| |||
747 | 706 | | |
748 | 707 | | |
749 | 708 | | |
750 | | - | |
| 709 | + | |
751 | 710 | | |
752 | 711 | | |
753 | 712 | | |
| |||
763 | 722 | | |
764 | 723 | | |
765 | 724 | | |
766 | | - | |
| 725 | + | |
767 | 726 | | |
768 | 727 | | |
769 | 728 | | |
| |||
797 | 756 | | |
798 | 757 | | |
799 | 758 | | |
800 | | - | |
| 759 | + | |
801 | 760 | | |
802 | 761 | | |
803 | 762 | | |
| |||
808 | 767 | | |
809 | 768 | | |
810 | 769 | | |
811 | | - | |
| 770 | + | |
812 | 771 | | |
813 | 772 | | |
814 | 773 | | |
| |||
835 | 794 | | |
836 | 795 | | |
837 | 796 | | |
838 | | - | |
| 797 | + | |
839 | 798 | | |
840 | 799 | | |
841 | 800 | | |
| |||
847 | 806 | | |
848 | 807 | | |
849 | 808 | | |
850 | | - | |
| 809 | + | |
851 | 810 | | |
852 | 811 | | |
853 | 812 | | |
| |||
869 | 828 | | |
870 | 829 | | |
871 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
872 | 837 | | |
873 | 838 | | |
874 | 839 | | |
| |||
1121 | 1086 | | |
1122 | 1087 | | |
1123 | 1088 | | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
1138 | | - | |
1139 | 1089 | | |
1140 | 1090 | | |
1141 | 1091 | | |
| |||
0 commit comments