Skip to content

Commit ca195dc

Browse files
authored
Merge pull request #14 from OptionalLion411/main
Add type hints
2 parents 0727614 + d19ab0e commit ca195dc

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

adafruit_display_notification/__init__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
import terminalio
1818

19+
try:
20+
from typing import List
21+
except ImportError:
22+
pass
23+
1924
__version__ = "0.0.0+auto.0"
2025
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git"
2126

@@ -27,7 +32,7 @@
2732
class NotificationFree(displayio.Group):
2833
"""Widget to show when no notifications are active."""
2934

30-
def __init__(self, width, height, *, dark_mode=True):
35+
def __init__(self, width: int, height: int, *, dark_mode: bool = True):
3136
# pylint: disable=unused-argument
3237
super().__init__()
3338

@@ -46,7 +51,15 @@ def __init__(self, width, height, *, dark_mode=True):
4651
class PlainNotification(displayio.Group):
4752
"""Plain text widget with a title and message."""
4853

49-
def __init__(self, title, message, width, height, *, dark_mode=True):
54+
def __init__(
55+
self,
56+
title: str,
57+
message: str,
58+
width: int,
59+
height: int,
60+
*,
61+
dark_mode: bool = True
62+
):
5063
super().__init__()
5164

5265
# Set text, font, and color
@@ -71,7 +84,7 @@ def __init__(self, title, message, width, height, *, dark_mode=True):
7184

7285
# cribbed from pyportal
7386
@staticmethod
74-
def _wrap_nicely(string, max_chars):
87+
def _wrap_nicely(string: str, max_chars: int) -> List[str]:
7588
"""A helper that will return a list of lines with word-break wrapping.
7689
:param str string: The text to be wrapped.
7790
:param int max_chars: The maximum number of characters on a line before wrapping.

adafruit_display_notification/apple.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@
1313

1414
from . import PlainNotification
1515

16+
try:
17+
# unused typing-import to prevent the other typing-only imports from being loaded at runtime
18+
from typing import Any # pylint: disable=unused-import
19+
20+
from adafruit_ble_apple_notification_center import Notification
21+
except ImportError:
22+
pass
23+
1624
__version__ = "0.0.0+auto.0"
1725
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git"
1826

1927

2028
def create_notification_widget(
21-
notification, max_width, max_height, *, color_count=2**16
22-
):
29+
notification: Notification,
30+
max_width: int,
31+
max_height: int,
32+
*,
33+
color_count: int = 2**16
34+
) -> PlainNotification:
2335
"""Creates a notification widget for the given Apple notification."""
2436
# pylint: disable=unused-argument
2537
return PlainNotification(

0 commit comments

Comments
 (0)