diff --git a/src/micropython/beta/typeshed.en.json b/src/micropython/beta/typeshed.en.json
index 61b85d873..9fc042be1 100644
--- a/src/micropython/beta/typeshed.en.json
+++ b/src/micropython/beta/typeshed.en.json
@@ -41,7 +41,7 @@
"/typeshed/stdlib/microbit/compass.pyi": "\"\"\"Use the built-in compass.\n\"\"\"\n\ndef calibrate() -> None:\n \"\"\"Starts the calibration process.\n\n Example: ``compass.calibrate()``\n\n An instructive message will be scrolled to the user after which they will need\n to rotate the device in order to draw a circle on the LED display.\n \"\"\"\n ...\n\ndef is_calibrated() -> bool:\n \"\"\"Check is the compass is calibrated.\n\n Example: ``compass.is_calibrated()``\n\n :return: ``True`` if the compass has been successfully calibrated, ``False`` otherwise.\n \"\"\"\n ...\n\ndef clear_calibration() -> None:\n \"\"\"Undoes the calibration, making the compass uncalibrated again.\n\n Example: ``compass.clear_calibration()``\n \"\"\"\n ...\n\ndef get_x() -> int:\n \"\"\"Get the magnetic field strength on the ``x`` axis.\n\n Example: ``compass.get_x()``\n\n Call ``calibrate`` first or the results will be inaccurate.\n\n :return: A positive or negative integer in nano tesla representing the magnitude and direction of the field.\n \"\"\"\n ...\n\ndef get_y() -> int:\n \"\"\"Get the magnetic field strength on the ``y`` axis.\n\n Example: ``compass.get_y()``\n\n Call ``calibrate`` first or the results will be inaccurate.\n\n :return: A positive or negative integer in nano tesla representing the magnitude and direction of the field.\n \"\"\"\n ...\n\ndef get_z() -> int:\n \"\"\"Get the magnetic field strength on the ``z`` axis.\n\n Example: ``compass.get_z()``\n\n Call ``calibrate`` first or the results will be inaccurate.\n\n :return: A positive or negative integer in nano tesla representing the magnitude and direction of the field.\n \"\"\"\n ...\n\ndef heading() -> int:\n \"\"\"Get the compass heading.\n\n Example: ``compass.heading()``\n\n :return: An integer in the range from 0 to 360, representing the angle in degrees, clockwise, with north as 0.\n \"\"\"\n ...\n\ndef get_field_strength() -> int:\n \"\"\"Get the magnitude of the magnetic field around the device.\n\n Example: ``compass.get_field_strength()``\n\n :return: An integer indication of the magnitude of the magnetic field in nano tesla.\"\"\"\n ...\n",
"/typeshed/stdlib/microbit/display.pyi": "\"\"\"Show text, images and animations on the 5\u00d75 LED display.\n\"\"\"\n\nfrom ..microbit import Image\nfrom typing import Union, overload, Iterable\n\ndef get_pixel(x: int, y: int) -> int:\n \"\"\"Get the brightness of the LED at column ``x`` and row ``y``.\n\n Example: ``display.get_pixel(0, 0)``\n\n :param x: The display column (0..4)\n :param y: The display row (0..4)\n :return: A number between 0 (off) and 9 (bright)\n \"\"\"\n ...\n\ndef set_pixel(x: int, y: int, value: int) -> None:\n \"\"\"Set the brightness of the LED at column ``x`` and row ``y``.\n\n Example: ``display.set_pixel(0, 0, 9)``\n\n :param x: The display column (0..4)\n :param y: The display row (0..4)\n :param value: The brightness between 0 (off) and 9 (bright)\n \"\"\"\n ...\n\ndef clear() -> None:\n \"\"\"Set the brightness of all LEDs to 0 (off).\n\n Example: ``display.clear()``\n \"\"\"\n ...\n\ndef show(\n image: Union[str, float, int, Image, Iterable[Image]],\n delay: int = 400,\n wait: bool = True,\n loop: bool = False,\n clear: bool = False,\n) -> None:\n \"\"\"Shows images, letters or digits on the LED display.\n\n Example: ``display.show(Image.HEART)``\n\n When ``image`` is an image or a list of images then each image is displayed in turn.\n If ``image`` is a string or number, each letter or digit is displayed in turn.\n\n :param image: A string, number, image or list of images to show.\n :param delay: Each letter, digit or image is shown with ``delay`` milliseconds between them.\n :param wait: If ``wait`` is ``True``, this function will block until the animation is finished, otherwise the animation will happen in the background.\n :param loop: If ``loop`` is ``True``, the animation will repeat forever.\n :param clear: If ``clear`` is ``True``, the display will be cleared after the sequence has finished.\n\n The ``wait``, ``loop`` and ``clear`` arguments must be specified using their keyword.\n \"\"\"\n ...\n\ndef scroll(\n text: Union[str, float, int],\n delay: int = 150,\n wait: bool = True,\n loop: bool = False,\n monospace: bool = False,\n) -> None:\n \"\"\"Scrolls a number or text on the LED display.\n\n Example: ``display.scroll('micro:bit')``\n\n :param text: The string to scroll. If ``text`` is an integer or float it is first converted to a string using ``str()``.\n :param delay: The ``delay`` parameter controls how fast the text is scrolling.\n :param wait: If ``wait`` is ``True``, this function will block until the animation is finished, otherwise the animation will happen in the background.\n :param loop: If ``loop`` is ``True``, the animation will repeat forever.\n :param monospace: If ``monospace`` is ``True``, the characters will all take up 5 pixel-columns in width, otherwise there will be exactly 1 blank pixel-column between each character as they scroll.\n\n The ``wait``, ``loop`` and ``monospace`` arguments must be specified\n using their keyword.\n \"\"\"\n ...\n\ndef on() -> None:\n \"\"\"Turn on the LED display.\n\n Example: ``display.on()``\n \"\"\"\n ...\n\ndef off() -> None:\n \"\"\"Turn off the LED display (disabling the display allows you to re-use the GPIO pins for other purposes).\n\n Example: ``display.off()``\n \"\"\"\n ...\n\ndef is_on() -> bool:\n \"\"\"Check whether the LED display is enabled.\n\n Example: ``display.is_on()``\n\n :return: ``True`` if the display is on, otherwise returns ``False``.\n \"\"\"\n ...\n\ndef read_light_level() -> int:\n \"\"\"Read the light level.\n\n Example: ``display.read_light_level()``\n\n Uses the display's LEDs in reverse-bias mode to sense the amount of light\n falling on the display.\n\n :return: An integer between 0 and 255 representing the light level, with larger meaning more light.\n \"\"\"\n ...\n",
"/typeshed/stdlib/microbit/i2c.pyi": "\"\"\"Communicate with devices using the I\u00b2C bus protocol.\n\"\"\"\n\nfrom _typeshed import ReadableBuffer\nfrom ..microbit import MicroBitDigitalPin, pin19, pin20\nfrom typing import List\n\ndef init(\n freq: int = 100000, sda: MicroBitDigitalPin = pin20, scl: MicroBitDigitalPin = pin19\n) -> None:\n \"\"\"Re-initialize a peripheral.\n\n Example: ``i2c.init()``\n\n :param freq: clock frequency\n :param sda: ``sda`` pin (default 20)\n :param scl: ``scl`` pin (default 19)\n\n On a micro:bit V1 board, changing the I\u00b2C pins from defaults will make\n the accelerometer and compass stop working, as they are connected\n internally to those pins. This warning does not apply to the **V2**\n revision of the micro:bit as this has `separate I\u00b2C lines `_\n for the motion sensors and the edge connector.\n \"\"\"\n ...\n\ndef scan() -> List[int]:\n \"\"\"Scan the bus for devices.\n\n Example: ``i2c.scan()``\n\n :return: A list of 7-bit addresses corresponding to those devices that responded to the scan.\n \"\"\"\n ...\n\ndef read(addr: int, n: int, repeat: bool = False) -> bytes:\n \"\"\"Read bytes from a device.\n\n Example: ``i2c.read(0x50, 64)``\n\n :param addr: The 7-bit address of the device\n :param n: The number of bytes to read\n :param repeat: If ``True``, no stop bit will be sent\n :return: The bytes read\n \"\"\"\n ...\n\ndef write(addr: int, buf: ReadableBuffer, repeat: bool = False) -> None:\n \"\"\"Write bytes to a device.\n\n Example: ``i2c.write(0x50, bytes([1, 2, 3]))``\n\n :param addr: The 7-bit address of the device\n :param buf: A buffer containing the bytes to write\n :param repeat: If ``True``, no stop bit will be sent\n \"\"\"\n ...\n",
- "/typeshed/stdlib/microbit/microphone.pyi": "\"\"\"Respond to sound using the built-in microphone (V2 only).\n\"\"\"\n\nfrom typing import Optional, Tuple\nfrom ..microbit import SoundEvent\nfrom ..microbit.audio import AudioFrame\n\ndef current_event() -> Optional[SoundEvent]:\n \"\"\"Get the last recorded sound event\n\n Example: ``microphone.current_event()``\n\n :return: The event, ``SoundEvent('loud')`` or ``SoundEvent('quiet')``.\n \"\"\"\n ...\n\ndef was_event(event: SoundEvent) -> bool:\n \"\"\"Check if a sound was heard at least once since the last call.\n\n Example: ``microphone.was_event(SoundEvent.LOUD)``\n\n This call clears the sound history before returning.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was heard at least once since the last call, otherwise ``False``.\n \"\"\"\n ...\n\ndef is_event(event: SoundEvent) -> bool:\n \"\"\"Check the most recent sound event detected.\n\n Example: ``microphone.is_event(SoundEvent.LOUD)``\n\n This call does not clear the sound event history.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was the most recent heard, ``False`` otherwise.\n \"\"\"\n ...\n\ndef get_events() -> Tuple[SoundEvent, ...]:\n \"\"\"Get the sound event history as a tuple.\n\n Example: ``microphone.get_events()``\n\n This call clears the sound history before returning.\n\n :return: A tuple of the event history with the most recent event last.\n \"\"\"\n ...\n\ndef set_threshold(event: SoundEvent, value: int) -> None:\n \"\"\"Set the threshold for a sound event.\n\n Example: ``microphone.set_threshold(SoundEvent.LOUD, 250)``\n\n The ``SoundEvent.LOUD`` event is triggered when the sound level crosses the \n threshold from \"quiet\" to \"loud\", and the ``SoundEvent.QUIET`` event is \n triggered when the sound level crosses from \"loud\" to \"quiet\".\n\n If the ``SoundEvent.LOUD`` threshold is set lower than the \n ``SoundEvent.QUIET`` threshold, then the ``SoundEvent.QUIET`` threshold \n will decrease by one unit below the ``SoundEvent.LOUD`` threshold. If the \n ``SoundEvent.QUIET`` threshold is set higher than the ``SoundEvent.LOUD``\n threshold, then the ``SoundEvent.LOUD`` threshold will increase by one unit \n above the ``SoundEvent.QUIET`` threshold.\n\n :param event: A sound event, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``.\n :param value: The threshold level in the range 0-255. Values outside this range will be clamped.\n \"\"\"\n ...\n\ndef sound_level() -> int:\n \"\"\"Get the sound pressure level.\n\n Example: ``microphone.sound_level()``\n\n :return: A representation of the sound pressure level in the range 0 to 255.\n \"\"\"\n ...\n\ndef record(duration: int, rate: int = 7812) -> AudioFrame:\n \"\"\"Record sound into an ``AudioFrame`` for the amount of time indicated by\n ``duration`` at the sampling rate indicated by ``rate``.\n\n Example: ``my_frame = microphone.record(3000)``\n\n The amount of memory consumed is directly related to the length of the\n recording and the sampling rate. The higher these values, the more memory\n it will use.\n\n A lower sampling rate will reduce both memory consumption and sound\n quality.\n\n If there isn't enough memory available a ``MemoryError`` will be raised.\n\n :param duration: How long to record in milliseconds.\n :param rate: Number of samples to capture per second.\n :return: An ``AudioFrame`` with the sound samples.\n \"\"\"\n ...\n\ndef record_into(buffer: AudioFrame, rate: int = 7812, wait: bool = True) -> None:\n \"\"\"Record sound into an existing ``AudioFrame`` until it is filled,\n or the ``stop_recording()`` function is called.\n\n Example: ``microphone.record_into(my_frame)``\n\n :param buffer: An ``AudioFrame`` to record sound.\n :param rate: Number of samples to capture per second.\n :param wait: When set to ``True`` it blocks until the recording is\n done, if it is set to ``False`` it will run in the background.\n \"\"\"\n ...\n\ndef is_recording() -> bool:\n \"\"\"Checks whether the microphone is currently recording.\n\n Example: ``is_recording = microphone.is_recording()``\n\n :return: ``True`` if the microphone is currently recording sound, otherwise returns ``False``.\n \"\"\"\n ...\n\ndef stop_recording() -> None:\n \"\"\"Stops a recording running in the background.\n\n Example: ``microphone.stop_recording()``\n \"\"\"\n ...\n\nSENSITIVITY_LOW: float;\n\"\"\"Low microphone sensitivity.\"\"\"\n\nSENSITIVITY_MEDIUM: float;\n\"\"\"Medium microphone sensitivity.\"\"\"\n\nSENSITIVITY_HIGH: float;\n\"\"\"High microphone sensitivity.\"\"\"\n\n\ndef set_sensitivity(gain: float) -> None:\n \"\"\"Configure the microphone sensitivity.\n\n Example: ``microphone.set_sensitivity(microphone.SENSITIVITY_HIGH)``\n\n The default sensitivity is ``microphone.SENSITIVITY_MEDIUM``.\n\n :param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, or a value between these levels.\n \"\"\"\n ...",
+ "/typeshed/stdlib/microbit/microphone.pyi": "\"\"\"Respond to sound using the built-in microphone (V2 only).\n\"\"\"\n\nfrom typing import Optional, Tuple\nfrom ..microbit import SoundEvent\nfrom ..microbit.audio import AudioFrame\n\ndef current_event() -> Optional[SoundEvent]:\n \"\"\"Get the last recorded sound event\n\n Example: ``microphone.current_event()``\n\n :return: The event, ``SoundEvent('loud')`` or ``SoundEvent('quiet')``.\n \"\"\"\n ...\n\ndef was_event(event: SoundEvent) -> bool:\n \"\"\"Check if a sound was heard at least once since the last call.\n\n Example: ``microphone.was_event(SoundEvent.LOUD)``\n\n This call clears the sound history before returning.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was heard at least once since the last call, otherwise ``False``.\n \"\"\"\n ...\n\ndef is_event(event: SoundEvent) -> bool:\n \"\"\"Check the most recent sound event detected.\n\n Example: ``microphone.is_event(SoundEvent.LOUD)``\n\n This call does not clear the sound event history.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was the most recent heard, ``False`` otherwise.\n \"\"\"\n ...\n\ndef get_events() -> Tuple[SoundEvent, ...]:\n \"\"\"Get the sound event history as a tuple.\n\n Example: ``microphone.get_events()``\n\n This call clears the sound history before returning.\n\n :return: A tuple of the event history with the most recent event last.\n \"\"\"\n ...\n\ndef set_threshold(event: SoundEvent, value: int) -> None:\n \"\"\"Set the threshold for a sound event.\n\n Example: ``microphone.set_threshold(SoundEvent.LOUD, 250)``\n\n The ``SoundEvent.LOUD`` event is triggered when the sound level crosses the \n threshold from \"quiet\" to \"loud\", and the ``SoundEvent.QUIET`` event is \n triggered when the sound level crosses from \"loud\" to \"quiet\".\n\n If the ``SoundEvent.LOUD`` threshold is set lower than the \n ``SoundEvent.QUIET`` threshold, then the ``SoundEvent.QUIET`` threshold \n will decrease by one unit below the ``SoundEvent.LOUD`` threshold. If the \n ``SoundEvent.QUIET`` threshold is set higher than the ``SoundEvent.LOUD``\n threshold, then the ``SoundEvent.LOUD`` threshold will increase by one unit \n above the ``SoundEvent.QUIET`` threshold.\n\n :param event: A sound event, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``.\n :param value: The threshold level in the range 0-255. Values outside this range will be clamped.\n \"\"\"\n ...\n\ndef sound_level() -> int:\n \"\"\"Get the sound pressure level in the range 0 to 255.\n\n Example: ``microphone.sound_level()``\n\n :return: A representation of the sound pressure level in the range 0 to 255.\n \"\"\"\n ...\n\ndef sound_level_db() -> int:\n \"\"\"Get the sound pressure level in decibels.\n\n Example: ``microphone.sound_level_db()``\n\n :return: A representation of the sound pressure level in decibels (dB).\n \"\"\"\n ...\n\ndef record(duration: int, rate: int = 7812) -> AudioFrame:\n \"\"\"Record sound into an ``AudioFrame`` for the amount of time indicated by\n ``duration`` at the sampling rate indicated by ``rate``.\n\n Example: ``my_frame = microphone.record(3000)``\n\n The amount of memory consumed is directly related to the length of the\n recording and the sampling rate. The higher these values, the more memory\n it will use.\n\n A lower sampling rate will reduce both memory consumption and sound\n quality.\n\n If there isn't enough memory available a ``MemoryError`` will be raised.\n\n :param duration: How long to record in milliseconds.\n :param rate: Number of samples to capture per second.\n :return: An ``AudioFrame`` with the sound samples.\n \"\"\"\n ...\n\ndef record_into(buffer: AudioFrame, rate: int = 7812, wait: bool = True) -> None:\n \"\"\"Record sound into an existing ``AudioFrame`` until it is filled,\n or the ``stop_recording()`` function is called.\n\n Example: ``microphone.record_into(my_frame)``\n\n :param buffer: An ``AudioFrame`` to record sound.\n :param rate: Number of samples to capture per second.\n :param wait: When set to ``True`` it blocks until the recording is\n done, if it is set to ``False`` it will run in the background.\n \"\"\"\n ...\n\ndef is_recording() -> bool:\n \"\"\"Checks whether the microphone is currently recording.\n\n Example: ``is_recording = microphone.is_recording()``\n\n :return: ``True`` if the microphone is currently recording sound, otherwise returns ``False``.\n \"\"\"\n ...\n\ndef stop_recording() -> None:\n \"\"\"Stops a recording running in the background.\n\n Example: ``microphone.stop_recording()``\n \"\"\"\n ...\n\nSENSITIVITY_LOW: float;\n\"\"\"Low microphone sensitivity.\"\"\"\n\nSENSITIVITY_MEDIUM: float;\n\"\"\"Medium microphone sensitivity.\"\"\"\n\nSENSITIVITY_HIGH: float;\n\"\"\"High microphone sensitivity.\"\"\"\n\n\ndef set_sensitivity(gain: float) -> None:\n \"\"\"Configure the microphone sensitivity.\n\n Example: ``microphone.set_sensitivity(microphone.SENSITIVITY_HIGH)``\n\n The default sensitivity is ``microphone.SENSITIVITY_MEDIUM``.\n\n :param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, or a value between these levels.\n \"\"\"\n ...",
"/typeshed/stdlib/microbit/speaker.pyi": "\"\"\"Control the built-in speaker (V2 only).\n\"\"\"\n\ndef off() -> None:\n \"\"\"Turn the speaker off.\n\n Example: ``speaker.off()``\n\n This does not disable sound output to an edge connector pin.\n \"\"\"\n ...\n\ndef on() -> None:\n \"\"\"Turn the speaker on.\n\n Example: ``speaker.on()``\n \"\"\"\n ...\n",
"/typeshed/stdlib/microbit/spi.pyi": "\"\"\"Communicate with devices using the serial peripheral interface (SPI) bus.\n\"\"\"\n\nfrom _typeshed import ReadableBuffer, WriteableBuffer\nfrom ..microbit import pin13, pin14, pin15, MicroBitDigitalPin\n\ndef init(\n baudrate: int = 1000000,\n bits: int = 8,\n mode: int = 0,\n sclk: MicroBitDigitalPin = pin13,\n mosi: MicroBitDigitalPin = pin15,\n miso: MicroBitDigitalPin = pin14,\n) -> None:\n \"\"\"Initialize SPI communication.\n\n Example: ``spi.init()``\n\n For correct communication, the parameters have to be the same on both communicating devices.\n\n :param baudrate: The speed of communication.\n :param bits: The width in bits of each transfer. Currently only ``bits=8`` is supported. However, this may change in the future.\n :param mode: Determines the combination of clock polarity and phase - `see online table `_.\n :param sclk: sclk pin (default 13)\n :param mosi: mosi pin (default 15)\n :param miso: miso pin (default 14)\n \"\"\"\n ...\n\ndef read(nbytes: int) -> bytes:\n \"\"\"Read bytes.\n\n Example: ``spi.read(64)``\n\n :param nbytes: Maximum number of bytes to read.\n :return: The bytes read.\n \"\"\"\n ...\n\ndef write(buffer: ReadableBuffer) -> None:\n \"\"\"Write bytes to the bus.\n\n Example: ``spi.write(bytes([1, 2, 3]))``\n\n :param buffer: A buffer to read data from.\n \"\"\"\n ...\n\ndef write_readinto(out: WriteableBuffer, in_: ReadableBuffer) -> None:\n \"\"\"Write the ``out`` buffer to the bus and read any response into the ``in_`` buffer.\n\n Example: ``spi.write_readinto(out_buffer, in_buffer)``\n\n The length of the buffers should be the same. The buffers can be the same object.\n\n :param out: The buffer to write any response to.\n :param in_: The buffer to read data from.\n \"\"\"\n ...\n",
"/typeshed/stdlib/microbit/uart.pyi": "\"\"\"Communicate with a device using a serial interface.\n\"\"\"\n\nfrom _typeshed import WriteableBuffer\nfrom ..microbit import MicroBitDigitalPin\nfrom typing import Optional, Union\n\nODD: int\n\"\"\"Odd parity\"\"\"\n\nEVEN: int\n\"\"\"Even parity\"\"\"\n\ndef init(\n baudrate: int = 9600,\n bits: int = 8,\n parity: Optional[int] = None,\n stop: int = 1,\n tx: Optional[MicroBitDigitalPin] = None,\n rx: Optional[MicroBitDigitalPin] = None,\n) -> None:\n \"\"\"Initialize serial communication.\n\n Example: ``uart.init(115200, tx=pin0, rx=pin1)``\n\n :param baudrate: The speed of communication.\n :param bits: The size of bytes being transmitted. micro:bit only supports 8.\n :param parity: How parity is checked, ``None``, ``uart.ODD`` or ``uart.EVEN``.\n :param stop: The number of stop bits, has to be 1 for micro:bit.\n :param tx: Transmitting pin.\n :param rx: Receiving pin.\n\n Initializing the UART on external pins will cause the Python console on\n USB to become unaccessible, as it uses the same hardware. To bring the\n console back you must reinitialize the UART without passing anything for\n ``tx`` or ``rx`` (or passing ``None`` to these arguments). This means\n that calling ``uart.init(115200)`` is enough to restore the Python console.\n\n For more details see `the online documentation `_.\n \"\"\"\n ...\n\ndef any() -> bool:\n \"\"\"Check if any data is waiting.\n\n Example: ``uart.any()``\n\n :return: ``True`` if any data is waiting, else ``False``.\n \"\"\"\n ...\n\ndef read(nbytes: Optional[int] = None) -> Optional[bytes]:\n \"\"\"Read bytes.\n\n Example: ``uart.read()``\n\n :param nbytes: If ``nbytes`` is specified then read at most that many bytes, otherwise read as many bytes as possible\n :return: A bytes object or ``None`` on timeout\n \"\"\"\n ...\n\ndef readinto(buf: WriteableBuffer, nbytes: Optional[int] = None) -> Optional[int]:\n \"\"\"Read bytes into the ``buf``.\n\n Example: ``uart.readinto(input_buffer)``\n\n :param buf: The buffer to write to.\n :param nbytes: If ``nbytes`` is specified then read at most that many bytes, otherwise read ``len(buf)`` bytes.\n :return: number of bytes read and stored into ``buf`` or ``None`` on timeout.\n \"\"\"\n ...\n\ndef readline() -> Optional[bytes]:\n \"\"\"Read a line, ending in a newline character.\n\n Example: ``uart.readline()``\n\n :return: The line read or ``None`` on timeout. The newline character is included in the returned bytes.\n \"\"\"\n ...\n\ndef write(buf: Union[bytes, str]) -> Optional[int]:\n \"\"\"Write a buffer to the bus.\n\n Example: ``uart.write('hello world')``\n\n :param buf: A bytes object or a string.\n :return: The number of bytes written, or ``None`` on timeout.\n\n Examples::\n\n uart.write('hello world')\n uart.write(b'hello world')\n uart.write(bytes([1, 2, 3]))\n \"\"\"\n ...\n",