Skip to content

Commit 4a3f601

Browse files
committed
add type annotations
1 parent 96d17e7 commit 4a3f601

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

adafruit_ble_berrymed_pulse_oximeter/adafruit_ble_transparent_uart.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
This module provides Services used by MicroChip
1111
1212
"""
13-
1413
from adafruit_ble import Service
1514
from adafruit_ble.uuid import VendorUUID
1615
from adafruit_ble.characteristics.stream import StreamOut, StreamIn
1716

17+
try:
18+
from typing import Union
19+
except ImportError:
20+
pass
21+
1822
__version__ = "0.0.0-auto.0"
1923
__repo__ = (
2024
"https://github.com/adafruit/Adafruit_CircuitPython_BLE_Contec_Pulse_Oximeter.git"
@@ -44,7 +48,7 @@ class TransparentUARTService(Service):
4448
buffer_size=64,
4549
)
4650

47-
def __init__(self, service=None):
51+
def __init__(self, service: Union[Service, None] = None):
4852
super().__init__(service=service)
4953
self.connectable = True
5054
if not service:
@@ -55,7 +59,7 @@ def __init__(self, service=None):
5559
self._tx = self._server_rx
5660
self._rx = self._server_tx
5761

58-
def read(self, nbytes=None):
62+
def read(self, nbytes: Union[bytes, None] = None) -> Union[bytes, None]:
5963
"""
6064
Read characters. If ``nbytes`` is specified then read at most that many bytes.
6165
Otherwise, read everything that arrives until the connection times out.
@@ -66,7 +70,9 @@ def read(self, nbytes=None):
6670
"""
6771
return self._rx.read(nbytes)
6872

69-
def readinto(self, buf, nbytes=None):
73+
def readinto(
74+
self, buf: bytes, nbytes: Union[bytes, None] = None
75+
) -> Union[int, None]:
7076
"""
7177
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
7278
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
@@ -76,7 +82,7 @@ def readinto(self, buf, nbytes=None):
7682
"""
7783
return self._rx.readinto(buf, nbytes)
7884

79-
def readline(self):
85+
def readline(self) -> Union[int, None]:
8086
"""
8187
Read a line, ending in a newline character.
8288
@@ -86,14 +92,14 @@ def readline(self):
8692
return self._rx.readline()
8793

8894
@property
89-
def in_waiting(self):
95+
def in_waiting(self) -> int:
9096
"""The number of bytes in the input buffer, available to be read."""
9197
return self._rx.in_waiting
9298

93-
def reset_input_buffer(self):
99+
def reset_input_buffer(self) -> None:
94100
"""Discard any unread characters in the input buffer."""
95101
self._rx.reset_input_buffer()
96102

97-
def write(self, buf):
103+
def write(self, buf: bytes) -> None:
98104
"""Write a buffer of bytes."""
99105
self._tx.write(buf)

0 commit comments

Comments
 (0)