Skip to content

Commit 903699d

Browse files
authored
Merge pull request #4 from tekktrik/doc/add-typing
Add type annotations
2 parents ba4f432 + 762e650 commit 903699d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

adafruit_ble_lywsd03mmc.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
from adafruit_ble.uuid import VendorUUID
3030
from adafruit_ble.characteristics import Characteristic, ComplexCharacteristic
3131

32+
try:
33+
from typing import Optional, Tuple
34+
except ImportError:
35+
pass
36+
3237
__version__ = "0.0.0-auto.0"
3338
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_LYWSD03MMC.git"
3439

@@ -38,10 +43,10 @@ class _Readings(ComplexCharacteristic):
3843

3944
uuid = VendorUUID("ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6")
4045

41-
def __init__(self):
46+
def __init__(self) -> None:
4247
super().__init__(properties=Characteristic.NOTIFY)
4348

44-
def bind(self, service):
49+
def bind(self, service: "LYWSD03MMCService") -> _bleio.PacketBuffer:
4550
"""Bind to an LYWSD03MMCService."""
4651
bound_characteristic = super().bind(service)
4752
bound_characteristic.set_cccd(notify=True)
@@ -52,7 +57,7 @@ def bind(self, service):
5257
class LYWSD03MMCService(Service):
5358
"""Service for reading from an LYWSD03MMC sensor."""
5459

55-
def __init__(self, service=None):
60+
def __init__(self, service: Optional["LYWSD03MMCService"] = None) -> None:
5661
super().__init__(service=service)
5762
# Defer creating buffers until needed, since MTU is not known yet.
5863
self._settings_result_buf = None
@@ -63,7 +68,7 @@ def __init__(self, service=None):
6368
readings = _Readings()
6469

6570
@property
66-
def temperature_humidity(self):
71+
def temperature_humidity(self) -> Optional[Tuple[float, int]]:
6772
"""Return a tuple of (temperature, humidity)."""
6873
if self._readings_buf is None:
6974
self._readings_buf = bytearray(self.readings.incoming_packet_length)

0 commit comments

Comments
 (0)