Skip to content

Commit

Permalink
Relax _check_is_adapters_tuple_iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobessa committed Dec 4, 2024
1 parent ccf0da0 commit 70e7327
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions vintasend/services/notification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,26 @@ def __init__(
(get_class_path(adapter), get_class_path(adapter.template_renderer)) for adapter in self.notification_adapters
]

def _check_is_base_notification_adapter_iterable(self, notification_adapters: Iterable[A] | Iterable[tuple[str, str]] | None) -> TypeGuard[Iterable[A]]:
return notification_adapters is not None and all(isinstance(adapter, BaseNotificationAdapter) for adapter in notification_adapters)
def _check_is_base_notification_adapter_iterable(
self,
notification_adapters: Iterable[A] | Iterable[tuple[str, str]] | None
) -> TypeGuard[Iterable[A]]:
return notification_adapters is not None and all(
isinstance(adapter, BaseNotificationAdapter)
for adapter in notification_adapters
)

def _check_is_adapters_tuple_iterable(self, notification_adapters: Iterable[A] | Iterable[tuple[str, str]] | None) -> TypeGuard[Iterable[tuple[str, str]]]:
return notification_adapters is not None and all(isinstance(adapter, tuple) and len(adapter) == 2 and isinstance(adapter[0], str) and isinstance(adapter[1], str) for adapter in notification_adapters)
def _check_is_adapters_tuple_iterable(
self,
notification_adapters: Iterable[A] | Iterable[tuple[str, str]] | None
) -> TypeGuard[Iterable[tuple[str, str]]]:
return notification_adapters is not None and all(
(isinstance(adapter, tuple) or isinstance(adapter, list))
and len(adapter) == 2
and isinstance(adapter[0], str)
and isinstance(adapter[1], str)
for adapter in notification_adapters
)

def send(self, notification: Notification) -> None:
"""
Expand Down

0 comments on commit 70e7327

Please sign in to comment.