Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stubs/pyserial/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion stubs/pyserial/serial/rs485.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from _typeshed import ReadableBuffer

import serial

class RS485Settings:
Expand All @@ -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: ...
8 changes: 4 additions & 4 deletions stubs/pyserial/serial/serialutil.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion stubs/pyserial/serial/threaded/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this calls Serial.write and the three variants are annotated as returning int | None, I don't think that's true? When tracing the code it seems to always return int (or throw) for all three variants.

def close(self) -> None: ...
def connect(self) -> tuple[Self, _P]: ...
def __enter__(self) -> _P: ...
Expand Down
Loading