Skip to content

Commit 585ef0c

Browse files
committed
update to use Optional types, upgrade version of Blinka to allow including ReadableBuffer type
1 parent 4a3f601 commit 585ef0c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

adafruit_ble_berrymed_pulse_oximeter/adafruit_ble_transparent_uart.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
This module provides Services used by MicroChip
1111
1212
"""
13+
1314
from adafruit_ble import Service
1415
from adafruit_ble.uuid import VendorUUID
1516
from adafruit_ble.characteristics.stream import StreamOut, StreamIn
1617

1718
try:
18-
from typing import Union
19+
from typing import Optional
1920
except ImportError:
2021
pass
22+
from circuitpython_typing import ReadableBuffer
2123

2224
__version__ = "0.0.0-auto.0"
2325
__repo__ = (
@@ -48,7 +50,7 @@ class TransparentUARTService(Service):
4850
buffer_size=64,
4951
)
5052

51-
def __init__(self, service: Union[Service, None] = None):
53+
def __init__(self, service: Optional[Service] = None):
5254
super().__init__(service=service)
5355
self.connectable = True
5456
if not service:
@@ -59,7 +61,7 @@ def __init__(self, service: Union[Service, None] = None):
5961
self._tx = self._server_rx
6062
self._rx = self._server_tx
6163

62-
def read(self, nbytes: Union[bytes, None] = None) -> Union[bytes, None]:
64+
def read(self, nbytes: Optional[bytes] = None) -> Optional[bytes]:
6365
"""
6466
Read characters. If ``nbytes`` is specified then read at most that many bytes.
6567
Otherwise, read everything that arrives until the connection times out.
@@ -70,9 +72,7 @@ def read(self, nbytes: Union[bytes, None] = None) -> Union[bytes, None]:
7072
"""
7173
return self._rx.read(nbytes)
7274

73-
def readinto(
74-
self, buf: bytes, nbytes: Union[bytes, None] = None
75-
) -> Union[int, None]:
75+
def readinto(self, buf: bytes, nbytes: Optional[bytes] = None) -> Optional[int]:
7676
"""
7777
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
7878
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
@@ -82,7 +82,7 @@ def readinto(
8282
"""
8383
return self._rx.readinto(buf, nbytes)
8484

85-
def readline(self) -> Union[int, None]:
85+
def readline(self) -> Optional[bytes]:
8686
"""
8787
Read a line, ending in a newline character.
8888
@@ -100,6 +100,6 @@ def reset_input_buffer(self) -> None:
100100
"""Discard any unread characters in the input buffer."""
101101
self._rx.reset_input_buffer()
102102

103-
def write(self, buf: bytes) -> None:
103+
def write(self, buf: ReadableBuffer) -> None:
104104
"""Write a buffer of bytes."""
105105
self._tx.write(buf)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#
33
# SPDX-License-Identifier: Unlicense
44

5-
Adafruit-Blinka
5+
Adafruit-Blinka>=7.2.3
66
adafruit-circuitpython-ble

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Author details
3434
author="Adafruit Industries",
3535
author_email="[email protected]",
36-
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-ble"],
36+
install_requires=["Adafruit-Blinka>=7.2.3", "adafruit-circuitpython-ble"],
3737
# Choose your license
3838
license="MIT",
3939
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)