From 3442adbb59b99143752408438b9d9477da681a09 Mon Sep 17 00:00:00 2001 From: Connor Smith Date: Tue, 30 Sep 2025 13:51:57 +0100 Subject: [PATCH 1/3] pyserial: Update type yielded by grep from tuple to ListPortInfo --- stubs/pyserial/serial/tools/list_ports.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/pyserial/serial/tools/list_ports.pyi b/stubs/pyserial/serial/tools/list_ports.pyi index d40bb08961be..6c644b343ca2 100644 --- a/stubs/pyserial/serial/tools/list_ports.pyi +++ b/stubs/pyserial/serial/tools/list_ports.pyi @@ -1,11 +1,12 @@ import re import sys from collections.abc import Generator +from serial.tools.list_ports_common import ListPortInfo if sys.platform == "win32": from serial.tools.list_ports_windows import comports as comports else: from serial.tools.list_ports_posix import comports as comports -def grep(regexp: str | re.Pattern[str], include_links: bool = False) -> Generator[tuple[str, str, str], None, None]: ... +def grep(regexp: str | re.Pattern[str], include_links: bool = False) -> Generator[ListPortInfo, None, None]: ... def main() -> None: ... From 12269fd4a578caed633a00e6eabdb2271ed7bc45 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 13:11:43 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pyserial/serial/tools/list_ports.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/pyserial/serial/tools/list_ports.pyi b/stubs/pyserial/serial/tools/list_ports.pyi index 6c644b343ca2..8e4c71eecf62 100644 --- a/stubs/pyserial/serial/tools/list_ports.pyi +++ b/stubs/pyserial/serial/tools/list_ports.pyi @@ -1,6 +1,7 @@ import re import sys from collections.abc import Generator + from serial.tools.list_ports_common import ListPortInfo if sys.platform == "win32": From 27b5068dfd097244e947cf8f084ab4192e780de9 Mon Sep 17 00:00:00 2001 From: Connor Smith Date: Tue, 30 Sep 2025 14:20:28 +0100 Subject: [PATCH 3/3] Drop redundant None types in Generator type annotations Co-authored-by: Sebastian Rittau --- stubs/pyserial/serial/rfc2217.pyi | 4 ++-- stubs/pyserial/serial/serialutil.pyi | 2 +- stubs/pyserial/serial/tools/list_ports.pyi | 2 +- stubs/pyserial/serial/tools/list_ports_windows.pyi | 2 +- stubs/pyserial/serial/urlhandler/protocol_spy.pyi | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/stubs/pyserial/serial/rfc2217.pyi b/stubs/pyserial/serial/rfc2217.pyi index b7e751c14b06..39275b8b7e8f 100644 --- a/stubs/pyserial/serial/rfc2217.pyi +++ b/stubs/pyserial/serial/rfc2217.pyi @@ -183,5 +183,5 @@ class PortManager: def telnet_send_option(self, action: bytes, option: bytes) -> None: ... def rfc2217_send_subnegotiation(self, option: bytes, value: bytes = b"") -> None: ... def check_modem_lines(self, force_notification: bool = False) -> None: ... - def escape(self, data: bytes) -> Generator[bytes, None, None]: ... - def filter(self, data: bytes) -> Generator[bytes, None, None]: ... + def escape(self, data: bytes) -> Generator[bytes]: ... + def filter(self, data: bytes) -> Generator[bytes]: ... diff --git a/stubs/pyserial/serial/serialutil.pyi b/stubs/pyserial/serial/serialutil.pyi index 913fb4b16048..3b6f84adee50 100644 --- a/stubs/pyserial/serial/serialutil.pyi +++ b/stubs/pyserial/serial/serialutil.pyi @@ -149,4 +149,4 @@ class SerialBase(io.RawIOBase): def send_break(self, duration: float = 0.25) -> None: ... def read_all(self) -> bytes | None: ... def read_until(self, expected: bytes = b"\n", size: int | None = None) -> bytes: ... - def iread_until(self, expected: bytes = ..., size: int | None = ...) -> Generator[bytes, None, None]: ... + def iread_until(self, expected: bytes = ..., size: int | None = ...) -> Generator[bytes]: ... diff --git a/stubs/pyserial/serial/tools/list_ports.pyi b/stubs/pyserial/serial/tools/list_ports.pyi index 8e4c71eecf62..be96fdc686fb 100644 --- a/stubs/pyserial/serial/tools/list_ports.pyi +++ b/stubs/pyserial/serial/tools/list_ports.pyi @@ -9,5 +9,5 @@ if sys.platform == "win32": else: from serial.tools.list_ports_posix import comports as comports -def grep(regexp: str | re.Pattern[str], include_links: bool = False) -> Generator[ListPortInfo, None, None]: ... +def grep(regexp: str | re.Pattern[str], include_links: bool = False) -> Generator[ListPortInfo]: ... def main() -> None: ... diff --git a/stubs/pyserial/serial/tools/list_ports_windows.pyi b/stubs/pyserial/serial/tools/list_ports_windows.pyi index dc499e238ae3..b5ba02fc7714 100644 --- a/stubs/pyserial/serial/tools/list_ports_windows.pyi +++ b/stubs/pyserial/serial/tools/list_ports_windows.pyi @@ -74,5 +74,5 @@ if sys.platform == "win32": depth: int = 0, last_serial_number: str | None = None, ) -> str: ... - def iterate_comports() -> Generator[ListPortInfo, None, None]: ... + def iterate_comports() -> Generator[ListPortInfo]: ... def comports(include_links: bool = False) -> list[ListPortInfo]: ... diff --git a/stubs/pyserial/serial/urlhandler/protocol_spy.pyi b/stubs/pyserial/serial/urlhandler/protocol_spy.pyi index e1454586fabe..9020d7e07690 100644 --- a/stubs/pyserial/serial/urlhandler/protocol_spy.pyi +++ b/stubs/pyserial/serial/urlhandler/protocol_spy.pyi @@ -3,8 +3,8 @@ from typing import TextIO, type_check_only import serial -def sixteen(data: bytes) -> Generator[tuple[str, str] | tuple[None, None], None, None]: ... -def hexdump(data: bytes) -> Generator[tuple[int, str], None, None]: ... +def sixteen(data: bytes) -> Generator[tuple[str, str] | tuple[None, None]]: ... +def hexdump(data: bytes) -> Generator[tuple[int, str]]: ... @type_check_only class _Formatter: def rx(self, data: bytes) -> None: ...