Skip to content

Commit 1ef3d98

Browse files
Add type hints
1 parent 0727614 commit 1ef3d98

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818

1919

2020
def create_notification_widget(
21-
notification, max_width, max_height, *, color_count=2**16
22-
):
21+
notification: PlainNotification,
22+
max_width: int,
23+
max_height: int,
24+
*,
25+
color_count: int = 2**16
26+
) -> PlainNotification:
2327
"""Creates a notification widget for the given Apple notification."""
2428
# pylint: disable=unused-argument
2529
return PlainNotification(

0 commit comments

Comments
 (0)