Skip to content

Commit 98f1ec4

Browse files
committed
Annotate services/standard/hid.py
1 parent e5d828e commit 98f1ec4

File tree

1 file changed

+35
-7
lines changed
  • adafruit_ble/services/standard

1 file changed

+35
-7
lines changed

adafruit_ble/services/standard/hid.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* Author(s): Dan Halbert for Adafruit Industries
1212
1313
"""
14+
15+
from __future__ import annotations
16+
1417
import struct
1518

1619
from micropython import const
@@ -23,6 +26,11 @@
2326

2427
from .. import Service
2528

29+
try:
30+
from typing import Dict, Optional
31+
except ImportError:
32+
pass
33+
2634
__version__ = "0.0.0-auto.0"
2735
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE.git"
2836

@@ -165,7 +173,15 @@ class ReportIn:
165173

166174
uuid = StandardUUID(_REPORT_UUID_NUM)
167175

168-
def __init__(self, service, report_id, usage_page, usage, *, max_length):
176+
def __init__(
177+
self,
178+
service: Service,
179+
report_id: int,
180+
usage_page: bytes,
181+
usage: bytes,
182+
*,
183+
max_length: int,
184+
) -> None:
169185
self._characteristic = _bleio.Characteristic.add_to_service(
170186
service.bleio_service,
171187
self.uuid.bleio_uuid,
@@ -187,7 +203,7 @@ def __init__(self, service, report_id, usage_page, usage, *, max_length):
187203
initial_value=struct.pack("<BB", self._report_id, _REPORT_TYPE_INPUT),
188204
)
189205

190-
def send_report(self, report):
206+
def send_report(self, report: Dict) -> None:
191207
"""Send a report to the peers"""
192208
self._characteristic.value = report
193209

@@ -198,7 +214,15 @@ class ReportOut:
198214
# pylint: disable=too-few-public-methods
199215
uuid = StandardUUID(_REPORT_UUID_NUM)
200216

201-
def __init__(self, service, report_id, usage_page, usage, *, max_length):
217+
def __init__(
218+
self,
219+
service: Service,
220+
report_id: int,
221+
usage_page: bytes,
222+
usage: bytes,
223+
*,
224+
max_length: int,
225+
) -> None:
202226
self._characteristic = _bleio.Characteristic.add_to_service(
203227
service.bleio_service,
204228
self.uuid.bleio_uuid,
@@ -225,7 +249,7 @@ def __init__(self, service, report_id, usage_page, usage, *, max_length):
225249
)
226250

227251
@property
228-
def report(self):
252+
def report(self) -> Dict:
229253
"""The HID OUT report"""
230254
return self._characteristic.value
231255

@@ -320,14 +344,18 @@ class HIDService(Service):
320344
)
321345
"""Controls whether the device should be suspended (0) or not (1)."""
322346

323-
def __init__(self, hid_descriptor=DEFAULT_HID_DESCRIPTOR, service=None):
347+
def __init__(
348+
self,
349+
hid_descriptor: bytes = DEFAULT_HID_DESCRIPTOR,
350+
service: Optional[Service] = None,
351+
) -> None:
324352
super().__init__(report_map=hid_descriptor)
325353
if service:
326354
# TODO: Add support for connecting to a remote hid server.
327355
pass
328356
self._init_devices()
329357

330-
def _init_devices(self):
358+
def _init_devices(self) -> None:
331359
# pylint: disable=too-many-branches,too-many-statements,too-many-locals
332360
self.devices = []
333361
hid_descriptor = self.report_map
@@ -389,7 +417,7 @@ def _init_devices(self):
389417

390418
i += size
391419

392-
def get_report_info(collection, reports):
420+
def get_report_info(collection: Dict, reports: Dict) -> None:
393421
"""Gets info about hid reports"""
394422
for main in collection["mains"]:
395423
if "type" in main:

0 commit comments

Comments
 (0)