diff --git a/stubs/pyserial/@tests/stubtest_allowlist.txt b/stubs/pyserial/@tests/stubtest_allowlist.txt index 69717d5f7fd3..5a42b302756a 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist.txt @@ -10,7 +10,6 @@ serial.serialjava # No Java Communications API implementation found # but at runtime they are normal arguments that don't have consistent names. serial.serialutil.SerialBase.readinto serial.rfc2217.Serial.write -serial.rs485.RS485.write serial.urlhandler.protocol_cp2110.Serial.write serial.urlhandler.protocol_loop.Serial.write serial.urlhandler.protocol_socket.Serial.write diff --git a/stubs/pyserial/serial/rs485.pyi b/stubs/pyserial/serial/rs485.pyi index b76617efb818..15b642b68b72 100644 --- a/stubs/pyserial/serial/rs485.pyi +++ b/stubs/pyserial/serial/rs485.pyi @@ -1,3 +1,5 @@ +from _typeshed import ReadableBuffer + import serial class RS485Settings: @@ -15,4 +17,5 @@ class RS485Settings: delay_before_rx: float | None = None, ) -> None: ... -class RS485(serial.Serial): ... +class RS485(serial.Serial): + def write(self, b: ReadableBuffer) -> None: ... diff --git a/stubs/pyserial/serial/serialutil.pyi b/stubs/pyserial/serial/serialutil.pyi index a21681d688e7..8d0464949db9 100644 --- a/stubs/pyserial/serial/serialutil.pyi +++ b/stubs/pyserial/serial/serialutil.pyi @@ -34,11 +34,11 @@ class Timeout: TIME: Callable[[], float] is_infinite: bool is_non_blocking: bool - duration: float - target_time: float - def __init__(self, duration: float) -> None: ... + duration: float | None + target_time: float | None + def __init__(self, duration: float | None) -> None: ... def expired(self) -> bool: ... - def time_left(self) -> float: ... + def time_left(self) -> float | None: ... def restart(self, duration: float) -> None: ... class SerialBase(io.RawIOBase): diff --git a/stubs/pyserial/serial/threaded/__init__.pyi b/stubs/pyserial/serial/threaded/__init__.pyi index 4cc3c15648ee..214ea0bbd45f 100644 --- a/stubs/pyserial/serial/threaded/__init__.pyi +++ b/stubs/pyserial/serial/threaded/__init__.pyi @@ -42,7 +42,8 @@ class ReaderThread(threading.Thread, Generic[_P]): protocol: _P def __init__(self, serial_instance: Serial, protocol_factory: Callable[[], _P]) -> None: ... def stop(self) -> None: ... - def write(self, data: ReadableBuffer) -> int: ... + # RS485.write discards the underlying byte count and returns None. + def write(self, data: ReadableBuffer) -> int | None: ... def close(self) -> None: ... def connect(self) -> tuple[Self, _P]: ... def __enter__(self) -> _P: ...