File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 88Types needed for type annotation that are not in `typing`
99
1010
11- * Author(s): Alec Delaney, Dan Halbert
11+ * Author(s): Alec Delaney, Dan Halbert, Randy Hudson
1212"""
1313
1414__version__ = "0.0.0-auto.0"
1515__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Typing.git"
1616
17- from typing import Union
17+ from typing import Union , Protocol , Optional
1818from array import array
1919
2020ReadableBuffer = Union [bytes , bytearray , memoryview , array ]
3131 * `memoryview`
3232 * `array.array`
3333"""
34+
35+
36+ class ByteStream (Protocol ):
37+ """Protocol for basic I/O operations on a byte stream.
38+ Classes which implement this protocol include
39+ * `io.BytesIO`
40+ * `io.FileIO` (for a file open in binary mode)
41+ * `busio.UART`
42+ * `usb_cdc.Serial`
43+ """
44+
45+ def read (self , count : Optional [int ] = None , / ) -> Optional [bytes ]:
46+ """Read ``count`` bytes from the stream.
47+ If ``count`` bytes are not immediately available,
48+ or if the parameter is not specified in the call,
49+ the outcome is implementation-dependent.
50+ """
51+ ...
52+
53+ def write (self , buf : ReadableBuffer , / ) -> Optional [int ]:
54+ """Write the bytes in ``buf`` to the stream."""
55+ ...
You can’t perform that action at this time.
0 commit comments