mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-27 19:57:02 +00:00
pybricks.common.BLE: Improve typing for broadcast() and observe()
- Add overloads for broadcast(). It accepts either a single value, or a tuple, or a list. - Adjust return type of observe(). It either returns a single value, or a tuple.
This commit is contained in:
committed by
Laurens Valk
parent
7411a246c9
commit
7014f46441
+21
-1
@@ -1448,7 +1448,22 @@ class BLE:
|
||||
.. versionadded:: 3.3
|
||||
"""
|
||||
|
||||
@overload
|
||||
def broadcast(
|
||||
self, data: Iterable[Union[bool, int, float, str, bytes]]
|
||||
) -> MaybeAwaitable:
|
||||
...
|
||||
|
||||
@overload
|
||||
def broadcast(self, data: Union[bool, int, float, str, bytes]) -> MaybeAwaitable:
|
||||
...
|
||||
|
||||
def broadcast(
|
||||
self,
|
||||
data: Union[
|
||||
Iterable[Union[bool, int, float, str, bytes]], bool, int, float, str, bytes
|
||||
],
|
||||
) -> MaybeAwaitable:
|
||||
"""broadcast(data)
|
||||
|
||||
Starts broadcasting the given data on
|
||||
@@ -1479,7 +1494,12 @@ class BLE:
|
||||
|
||||
def observe(
|
||||
self, channel: int
|
||||
) -> Optional[Tuple[Union[bool, int, float, str, bytes], ...]]:
|
||||
) -> Optional[
|
||||
Union[
|
||||
Tuple[Union[bool, int, float, str, bytes], ...],
|
||||
Union[bool, int, float, str, bytes],
|
||||
]
|
||||
]:
|
||||
"""observe(channel) -> bool | int | float | str | bytes | tuple | None
|
||||
|
||||
Retrieves the last observed data for a given channel.
|
||||
|
||||
Reference in New Issue
Block a user