Skip to content

Commit 5e2f3e5

Browse files
authored
Merge pull request #16 from tekktrik/doc/add-typing
Add type annotations
2 parents 5a1bb33 + 265b965 commit 5e2f3e5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

adafruit_ble_heart_rate.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
from adafruit_ble.characteristics import Characteristic, ComplexCharacteristic
3333
from adafruit_ble.characteristics.int import Uint8Characteristic
3434

35+
try:
36+
from typing import Optional
37+
except ImportError:
38+
pass
39+
3540
__version__ = "0.0.0-auto.0"
3641
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_Heart_Rate.git"
3742

@@ -73,10 +78,10 @@ class _HeartRateMeasurement(ComplexCharacteristic):
7378

7479
uuid = StandardUUID(0x2A37)
7580

76-
def __init__(self):
81+
def __init__(self) -> None:
7782
super().__init__(properties=Characteristic.NOTIFY)
7883

79-
def bind(self, service):
84+
def bind(self, service: "HeartRateService") -> _bleio.PacketBuffer:
8085
"""Bind to a HeartRateService."""
8186
bound_characteristic = super().bind(service)
8287
bound_characteristic.set_cccd(notify=True)
@@ -120,13 +125,13 @@ class HeartRateService(Service):
120125

121126
_BODY_LOCATIONS = ("Other", "Chest", "Wrist", "Finger", "Hand", "Ear Lobe", "Foot")
122127

123-
def __init__(self, service=None):
128+
def __init__(self, service: Optional["HeartRateService"] = None) -> None:
124129
super().__init__(service=service)
125130
# Defer creating buffer until needed.
126131
self._measurement_buf = None
127132

128133
@property
129-
def measurement_values(self):
134+
def measurement_values(self) -> Optional[_HeartRateMeasurement]:
130135
"""All the measurement values, returned as a HeartRateMeasurementValues
131136
namedtuple.
132137
@@ -174,7 +179,7 @@ def measurement_values(self):
174179
return HeartRateMeasurementValues(bpm, contact, energy_expended, rr_values)
175180

176181
@property
177-
def location(self):
182+
def location(self) -> str:
178183
"""The location of the sensor on the human body, as a string.
179184
180185
Note that the specification describes a limited number of locations.

0 commit comments

Comments
 (0)