service
dev_tool.services.notification.service
Notification
dataclass
A data class representing a single notification with expiration logic.
This class contains notification details including message, type, format, timing information, and display preferences.
message
instance-attribute
notification_type
instance-attribute
notification_format
instance-attribute
timestamp
instance-attribute
duration = 5.0
class-attribute
instance-attribute
persistent = False
class-attribute
instance-attribute
show_prefix = False
class-attribute
instance-attribute
identifier = None
class-attribute
instance-attribute
expired
property
A property that checks if notification has expired based on timestamp and duration.
Returns:
-
bool–True if the notification has expired, False otherwise.
remaining_time
property
A property that calculates remaining display time for non-persistent notifications.
Returns:
-
float–The remaining time in seconds, or infinity for persistent notifications.
NotificationService
A thread-safe singleton service for managing application notifications.
This class provides centralized notification management with support for different notification types, formats, and lifecycle management.
The constructor for the NotificationService class.
Initializes the service with an empty notification list and thread safety.
Source code in dev_tool/services/notification/service.py
__new__
A class method that creates a singleton instance with thread safety.
Returns:
-
Self–The singleton NotificationService instance.
Source code in dev_tool/services/notification/service.py
add_notification
A method that adds a new notification to the active list.
Parameters:
-
message(str) –The notification message text.
-
notification_type(NotificationType, default:INFO) –The type of notification for styling.
-
notification_format(NotificationFormat, default:BANNER) –The display format for the notification.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the notification type prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
clear
dismiss
A method that removes a specific notification from the active list.
Parameters:
-
notification(Notification) –The notification object to remove.
Source code in dev_tool/services/notification/service.py
dismiss_by_identifier
A method that removes notifications with a specific identifier.
Parameters:
-
identifier(str) –The identifier to match for removal.
Source code in dev_tool/services/notification/service.py
error
A method that adds an error notification with red styling.
Parameters:
-
message(str) –The error message text.
-
duration(float, default:10.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the error prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
error_banner
A method that adds an error notification with banner format.
Parameters:
-
message(str) –The error message text.
-
duration(float, default:10.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the error prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
error_text
A method that adds an error notification with text format.
Parameters:
-
message(str) –The error message text.
-
duration(float, default:10.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the error prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
flush
get_active
A method that gets active notifications and cleans up expired ones.
Returns:
-
list[Notification]–A list of active notification objects.
Source code in dev_tool/services/notification/service.py
info
A method that adds an info notification with blue styling.
Parameters:
-
message(str) –The info message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the info prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
info_banner
A method that adds an info notification with banner format.
Parameters:
-
message(str) –The info message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the info prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
info_text
A method that adds an info notification with text format.
Parameters:
-
message(str) –The info message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the info prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
normal
A method that adds a normal notification with plain styling.
Parameters:
-
message(str) –The notification message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the normal prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
normal_banner
A method that adds a normal notification with banner format.
Parameters:
-
message(str) –The notification message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the normal prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
normal_text
A method that adds a normal notification with text format.
Parameters:
-
message(str) –The notification message text.
-
duration(float, default:5.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the normal prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
success
A method that adds a success notification with green styling.
Parameters:
-
message(str) –The success message text.
-
duration(float, default:3.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the success prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
success_banner
A method that adds a success notification with banner format.
Parameters:
-
message(str) –The success message text.
-
duration(float, default:3.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the success prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
success_text
A method that adds a success notification with text format.
Parameters:
-
message(str) –The success message text.
-
duration(float, default:3.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the success prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
warning
A method that adds a warning notification with yellow styling.
Parameters:
-
message(str) –The warning message text.
-
duration(float, default:7.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
banner(bool, default:False) –Whether to use banner format instead of text format.
-
show_prefix(bool, default:False) –Whether to show the warning prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
warning_banner
A method that adds a warning notification with banner format.
Parameters:
-
message(str) –The warning message text.
-
duration(float, default:7.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the warning prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.
Source code in dev_tool/services/notification/service.py
warning_text
A method that adds a warning notification with text format.
Parameters:
-
message(str) –The warning message text.
-
duration(float, default:7.0) –The display duration in seconds.
-
persistent(bool, default:False) –Whether the notification should persist until dismissed.
-
show_prefix(bool, default:False) –Whether to show the warning prefix.
-
identifier(str | None, default:None) –Optional identifier for targeted dismissal.