Skip to content

Commit 77fc12e

Browse files
committed
Add Missing Type Annotations
1 parent 7c3c3f9 commit 77fc12e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_us100.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@
2525

2626
import time
2727

28+
try:
29+
from typing import Union
30+
from busio import UART
31+
except ImportError:
32+
pass
33+
2834

2935
class US100:
3036
"""Control a US-100 ultrasonic range sensor."""
3137

32-
def __init__(self, uart):
38+
def __init__(self, uart: UART):
3339
self._uart = uart
3440

3541
@property
36-
def distance(self):
42+
def distance(self) -> float:
3743
"""Return the distance measured by the sensor in cm.
3844
This is the function that will be called most often in user code.
3945
If no signal is received, return ``None``. This can happen when the
@@ -67,7 +73,7 @@ def distance(self):
6773
return dist
6874

6975
@property
70-
def temperature(self):
76+
def temperature(self) -> Union[None, int]:
7177
"""Return the on-chip temperature, in Celsius"""
7278
for _ in range(2): # Attempt to read twice.
7379
self._uart.write(bytes([0x50]))

0 commit comments

Comments
 (0)