Skip to content

Commit 207bc18

Browse files
authored
Merge pull request #2 from jreanah/add_type_hints
Added Union for optional types
2 parents c624456 + 99b7d02 commit 207bc18

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

adafruit_display_notification/__init__.py

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

1717
# For older versions, typing may need to be imported
1818
try:
19-
from typing import List, Tuple
19+
from typing import List, Tuple, Optional, Union
2020
except ImportError:
2121
pass
2222

@@ -31,7 +31,8 @@
3131
class NotificationFree(displayio.Group):
3232
"""Widget to show when no notifications are active."""
3333

34-
def __init__(self, width: int, height: int, *, dark_mode=True):
34+
def __init__(self, width: Union[int, float], height: Union[int, float], *,
35+
dark_mode: Union[bool, int]=True):
3536
# pylint: disable=unused-argument
3637
super().__init__()
3738

@@ -50,7 +51,8 @@ def __init__(self, width: int, height: int, *, dark_mode=True):
5051
class PlainNotification(displayio.Group):
5152
"""Plain text widget with a title and message."""
5253

53-
def __init__(self, title: str, message: str, width: int, height: int, *, dark_mode: bool=True):
54+
def __init__(self, title: str, message: str, width: Union[int, float], height: Union[int, float],
55+
*, dark_mode: Union[bool, int]=True):
5456
super().__init__()
5557

5658
# Set text, font, and color

adafruit_display_notification/apple.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313

1414
from . import PlainNotification
1515

16+
try:
17+
from typing import Union
18+
except ImportError:
19+
pass
20+
1621
__version__ = "0.0.0+auto.0"
1722
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git"
1823

1924

2025
def create_notification_widget(
21-
notification: object, max_width: int, max_height: int,
26+
notification: object, max_width: Union[int, float], max_height: Union[int, float],
2227
*, color_count: int=2**16):
2328
"""
2429
Creates a notification widget for the given Apple notification.

0 commit comments

Comments
 (0)