|
32 | 32 | from adafruit_ble.characteristics import Characteristic, ComplexCharacteristic |
33 | 33 | from adafruit_ble.characteristics.int import Uint8Characteristic |
34 | 34 |
|
| 35 | +try: |
| 36 | + from typing import Optional |
| 37 | +except ImportError: |
| 38 | + pass |
| 39 | + |
35 | 40 | __version__ = "0.0.0-auto.0" |
36 | 41 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_Heart_Rate.git" |
37 | 42 |
|
@@ -73,10 +78,10 @@ class _HeartRateMeasurement(ComplexCharacteristic): |
73 | 78 |
|
74 | 79 | uuid = StandardUUID(0x2A37) |
75 | 80 |
|
76 | | - def __init__(self): |
| 81 | + def __init__(self) -> None: |
77 | 82 | super().__init__(properties=Characteristic.NOTIFY) |
78 | 83 |
|
79 | | - def bind(self, service): |
| 84 | + def bind(self, service: "HeartRateService") -> _bleio.PacketBuffer: |
80 | 85 | """Bind to a HeartRateService.""" |
81 | 86 | bound_characteristic = super().bind(service) |
82 | 87 | bound_characteristic.set_cccd(notify=True) |
@@ -120,13 +125,13 @@ class HeartRateService(Service): |
120 | 125 |
|
121 | 126 | _BODY_LOCATIONS = ("Other", "Chest", "Wrist", "Finger", "Hand", "Ear Lobe", "Foot") |
122 | 127 |
|
123 | | - def __init__(self, service=None): |
| 128 | + def __init__(self, service: Optional["HeartRateService"] = None) -> None: |
124 | 129 | super().__init__(service=service) |
125 | 130 | # Defer creating buffer until needed. |
126 | 131 | self._measurement_buf = None |
127 | 132 |
|
128 | 133 | @property |
129 | | - def measurement_values(self): |
| 134 | + def measurement_values(self) -> Optional[_HeartRateMeasurement]: |
130 | 135 | """All the measurement values, returned as a HeartRateMeasurementValues |
131 | 136 | namedtuple. |
132 | 137 |
|
@@ -174,7 +179,7 @@ def measurement_values(self): |
174 | 179 | return HeartRateMeasurementValues(bpm, contact, energy_expended, rr_values) |
175 | 180 |
|
176 | 181 | @property |
177 | | - def location(self): |
| 182 | + def location(self) -> str: |
178 | 183 | """The location of the sensor on the human body, as a string. |
179 | 184 |
|
180 | 185 | Note that the specification describes a limited number of locations. |
|
0 commit comments