diff --git a/edc_action_item/action_with_notification.py b/edc_action_item/action_with_notification.py index e46ab78..3a214d8 100644 --- a/edc_action_item/action_with_notification.py +++ b/edc_action_item/action_with_notification.py @@ -1,4 +1,4 @@ -from typing import List +from typing import Type, cast from django.db import models @@ -12,10 +12,10 @@ class ActionWithNotification(Action): support for notifications. """ - notification_email_to: List[str] = None + notification_email_to: list[str] = None notification_display_name: str = None - notification_fields: List[str] = None - notification_super_cls = ActionItemNotification + notification_fields: list[str] = None + notification_super_cls: Type[ActionItemNotification] = ActionItemNotification notify_on_changed_reference_obj: models.Model = True notify_on_close: bool = False notify_on_new: bool = False @@ -23,24 +23,27 @@ class ActionWithNotification(Action): notify_on_open: bool = False @classmethod - def notification_cls(cls): + def notification_cls(cls) -> Type[ActionItemNotification]: """Returns a subclass of ActionItemModelNotification.""" - return type( - f"{cls.__name__}Notification", - (cls.notification_super_cls,), - dict( - name=f"{cls.name}-notification", - notification_action_name=cls.name, - display_name=( - cls.notification_display_name or f"{cls.display_name} Notification" + return cast( + Type[ActionItemNotification], + type( + f"{cls.__name__}Notification", + (cls.notification_super_cls,), + dict( + name=f"{cls.name}-notification", + notification_action_name=cls.name, + display_name=( + cls.notification_display_name or f"{cls.display_name} Notification" + ), + email_to=cls.notification_email_to, + notification_fields=cls.notification_fields, + model=cls.get_reference_model(), + notify_on_new_and_no_reference_obj=cls.notify_on_new_and_no_reference_obj, + notify_on_new=cls.notify_on_new, + notify_on_open=cls.notify_on_open, + notify_on_close=cls.notify_on_close, + notify_on_changed_reference_obj=cls.notify_on_changed_reference_obj, ), - email_to=cls.notification_email_to, - notification_fields=cls.notification_fields, - model=cls.get_reference_model(), - notify_on_new_and_no_reference_obj=cls.notify_on_new_and_no_reference_obj, - notify_on_new=cls.notify_on_new, - notify_on_open=cls.notify_on_open, - notify_on_close=cls.notify_on_close, - notify_on_changed_reference_obj=cls.notify_on_changed_reference_obj, ), ) diff --git a/edc_action_item/site_action_items.py b/edc_action_item/site_action_items.py index b29d6bd..ad16c31 100644 --- a/edc_action_item/site_action_items.py +++ b/edc_action_item/site_action_items.py @@ -169,7 +169,7 @@ def autodiscover(module_name=None, verbose=True): except Exception as e: raise SiteActionError( f"{e.__class__.__name__} was raised when loading {module_name}. " - f"Got {e} See {app}.{module_name}" + f'Got "{e}" See {app}.{module_name}' ) diff --git a/runtests.py b/runtests.py index 4490837..a20f0f4 100644 --- a/runtests.py +++ b/runtests.py @@ -12,6 +12,7 @@ BASE_DIR=base_dir, APP_NAME=app_name, ETC_DIR=str(base_dir / app_name / "tests" / "etc"), + EMAIL_ENABLED=True, SILENCED_SYSTEM_CHECKS=[ "edc_consent.E001", "sites.E101",