From 26bfe579e13ecddba04a02aed66ce7b834ef54fe Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 13 Nov 2026 19:58:24 -0600 Subject: [PATCH 1/3] Correct nullable pyserial Timeout values --- stubs/pyserial/serial/serialutil.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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): From fe988347a2d69c9f626f74397bfe162169aff355 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 13 Nov 2026 20:08:10 -0600 Subject: [PATCH 2/3] Include missing ReaderThread write results --- stubs/pyserial/serial/threaded/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pyserial/serial/threaded/__init__.pyi b/stubs/pyserial/serial/threaded/__init__.pyi index 4cc3c15648ee..07107ce727e3 100644 --- a/stubs/pyserial/serial/threaded/__init__.pyi +++ b/stubs/pyserial/serial/threaded/__init__.pyi @@ -42,7 +42,7 @@ 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: ... + def write(self, data: ReadableBuffer) -> int | None: ... def close(self) -> None: ... def connect(self) -> tuple[Self, _P]: ... def __enter__(self) -> _P: ... From cf75a30e07d273752a8bc2d65acae66581e15df4 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 14 Nov 2026 11:10:47 -0600 Subject: [PATCH 3/3] Declare RS485 write result explicitly --- stubs/pyserial/@tests/stubtest_allowlist.txt | 1 - stubs/pyserial/serial/rs485.pyi | 5 ++++- stubs/pyserial/serial/threaded/__init__.pyi | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) 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/threaded/__init__.pyi b/stubs/pyserial/serial/threaded/__init__.pyi index 07107ce727e3..214ea0bbd45f 100644 --- a/stubs/pyserial/serial/threaded/__init__.pyi +++ b/stubs/pyserial/serial/threaded/__init__.pyi @@ -42,6 +42,7 @@ class ReaderThread(threading.Thread, Generic[_P]): protocol: _P def __init__(self, serial_instance: Serial, protocol_factory: Callable[[], _P]) -> None: ... def stop(self) -> None: ... + # 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]: ...