diff --git a/adafruit_display_notification/__init__.py b/adafruit_display_notification/__init__.py index fbeb361..c2182b2 100755 --- a/adafruit_display_notification/__init__.py +++ b/adafruit_display_notification/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2019 Scott Shawcroft for Adafruit Industries -# + # SPDX-License-Identifier: MIT """ @@ -11,11 +11,15 @@ """ import displayio - from adafruit_display_text import label - import terminalio +# For older versions, typing may need to be imported +try: + from typing import List, Tuple, Optional, Union +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git" @@ -27,7 +31,8 @@ class NotificationFree(displayio.Group): """Widget to show when no notifications are active.""" - def __init__(self, width, height, *, dark_mode=True): + def __init__(self, width: Union[int, float], height: Union[int, float], *, + dark_mode: Union[bool, int]=True): # pylint: disable=unused-argument super().__init__() @@ -46,7 +51,8 @@ def __init__(self, width, height, *, dark_mode=True): class PlainNotification(displayio.Group): """Plain text widget with a title and message.""" - def __init__(self, title, message, width, height, *, dark_mode=True): + def __init__(self, title: str, message: str, width: Union[int, float], height: Union[int, float], + *, dark_mode: Union[bool, int]=True): super().__init__() # Set text, font, and color @@ -71,7 +77,7 @@ def __init__(self, title, message, width, height, *, dark_mode=True): # cribbed from pyportal @staticmethod - def _wrap_nicely(string, max_chars): + def _wrap_nicely(string: str, max_chars: int) -> List[str]: """A helper that will return a list of lines with word-break wrapping. :param str string: The text to be wrapped. :param int max_chars: The maximum number of characters on a line before wrapping. diff --git a/adafruit_display_notification/apple.py b/adafruit_display_notification/apple.py index 97a7ec9..6153778 100755 --- a/adafruit_display_notification/apple.py +++ b/adafruit_display_notification/apple.py @@ -13,14 +13,26 @@ from . import PlainNotification +try: + from typing import Union +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git" def create_notification_widget( - notification, max_width, max_height, *, color_count=2**16 -): - """Creates a notification widget for the given Apple notification.""" + notification: object, max_width: Union[int, float], max_height: Union[int, float], + *, color_count: int=2**16): + """ + Creates a notification widget for the given Apple notification. + :param notification object: Object with attributes title and message + :param max_width int: Max Width of the notification + :param max_height int: Max Height of the Notication + :param color_count int: Number of colors, default is 2**16 + + """ # pylint: disable=unused-argument return PlainNotification( notification.title, notification.message, max_width, max_height