Skip to content

Commit ccc18fb

Browse files
committed
Add Optional
1 parent e222fe3 commit ccc18fb

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

adafruit_clue.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"""
4141

4242
try:
43-
from typing import Union, Tuple
43+
from typing import Union, Tuple, Optional
4444
except ImportError:
4545
pass
4646

@@ -69,12 +69,12 @@ class _ClueSimpleTextDisplay:
6969

7070
def __init__( # pylint: disable=too-many-arguments
7171
self,
72-
title: str = None,
72+
title: Optional[str] = None,
7373
title_color: Union[int, Tuple] = 0xFFFFFF,
7474
title_scale: int = 1,
7575
text_scale: int = 1,
76-
font: str = None,
77-
colors: Tuple = None,
76+
font: Optional[str] = None,
77+
colors: Optional[Tuple[Tuple[int, int, int], ...]] = None,
7878
):
7979
# pylint: disable=import-outside-toplevel
8080
import displayio
@@ -138,7 +138,7 @@ def __getitem__(self, item: int):
138138
)
139139
return self._lines[item]
140140

141-
def add_text_line(self, color: int = 0xFFFFFF):
141+
def add_text_line(self, color: Union[int, Tuple[int, int, int]] = 0xFFFFFF):
142142
"""Adds a line on the display of the specified color and returns the label object."""
143143
text_label = self._label.Label(self._font, text="", color=color)
144144
text_label.x = 0
@@ -387,7 +387,7 @@ def shake(
387387
return total_accel > shake_threshold
388388

389389
@property
390-
def acceleration(self) -> Tuple:
390+
def acceleration(self) -> Tuple[int, int, int]:
391391
"""Obtain acceleration data from the x, y and z axes.
392392
393393
.. image :: ../docs/_static/accelerometer.jpg
@@ -407,7 +407,7 @@ def acceleration(self) -> Tuple:
407407
return self._accelerometer.acceleration
408408

409409
@property
410-
def gyro(self) -> Tuple:
410+
def gyro(self) -> Tuple[int, int, int]:
411411
"""Obtain x, y, z angular velocity values in degrees/second.
412412
413413
.. image :: ../docs/_static/accelerometer.jpg
@@ -427,7 +427,7 @@ def gyro(self) -> Tuple:
427427
return self._accelerometer.gyro
428428

429429
@property
430-
def magnetic(self) -> Tuple:
430+
def magnetic(self) -> Tuple[int, int, int]:
431431
"""Obtain x, y, z magnetic values in microteslas.
432432
433433
.. image :: ../docs/_static/magnetometer.jpg
@@ -469,7 +469,7 @@ def proximity(self) -> int:
469469
return self._sensor.proximity
470470

471471
@property
472-
def color(self) -> Tuple:
472+
def color(self) -> Tuple[int, int, int, int]:
473473
"""The red, green, blue, and clear light values. (r, g, b, c)
474474
475475
.. image :: ../docs/_static/proximity.jpg
@@ -619,7 +619,7 @@ def sea_level_pressure(self) -> float:
619619
return self._pressure.sea_level_pressure
620620

621621
@sea_level_pressure.setter
622-
def sea_level_pressure(self, value: int):
622+
def sea_level_pressure(self, value: float):
623623
self._pressure.sea_level_pressure = value
624624

625625
@property
@@ -702,7 +702,7 @@ def _generate_sample(self, length: int = 100):
702702
self._audio_out = audiopwmio.PWMAudioOut(board.SPEAKER)
703703
self._sine_wave_sample = audiocore.RawSample(self._sine_wave)
704704

705-
def play_tone(self, frequency: int, duration: int):
705+
def play_tone(self, frequency: int, duration: float):
706706
"""Produce a tone using the speaker. Try changing frequency to change
707707
the pitch of the tone.
708708
@@ -868,12 +868,12 @@ def loud_sound(self, sound_threshold: int = 200) -> bool:
868868

869869
@staticmethod
870870
def simple_text_display( # pylint: disable=too-many-arguments
871-
title: str = None,
871+
title: Optional[str] = None,
872872
title_color: Tuple = (255, 255, 255),
873873
title_scale: int = 1,
874874
text_scale: int = 1,
875-
font: str = None,
876-
colors: Tuple = None,
875+
font: Optional[str] = None,
876+
colors: Optional[Tuple[Tuple[int, int, int], ...]] = None,
877877
):
878878
"""Display lines of text on the CLUE display. Lines of text are created in order as shown
879879
in the example below. If you skip a number, the line will be shown blank on the display,

0 commit comments

Comments
 (0)