pybricks.tools: add read_input_byte()

This adds stubs and docs for the new `pybricks.tools.read_input_byte()`
function.
This commit is contained in:
David Lechner
2023-06-12 11:06:20 -05:00
parent 6d69f04fe5
commit 41b9ce71dd
3 changed files with 18 additions and 1 deletions
+5
View File
@@ -22,6 +22,11 @@ Timing tools
.. automethod:: pybricks.tools.StopWatch.reset
Input tools
-----------
.. autofunction:: pybricks.tools.read_input_byte
Linear algebra tools
--------------------
+1
View File
@@ -158,6 +158,7 @@ def test_from_pybricks_tools_import():
"cross",
"DataLog",
"Matrix",
"read_input_byte",
"StopWatch",
"vector",
"wait",
+12 -1
View File
@@ -5,7 +5,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Sequence, Tuple, overload
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, overload
if TYPE_CHECKING:
from .parameters import Number
@@ -222,6 +222,17 @@ def cross(a: Matrix, b: Matrix) -> Matrix:
"""
def read_input_byte() -> Optional[int]:
"""
read_input_byte() -> int | None
Reads one byte from standard input without blocking.
Returns:
The numeric value of the byte read or ``None`` if no data is available.
"""
# HACK: hide from jedi
if TYPE_CHECKING:
del Number