From 40c797ea6543162e1f4703540172daea655e33b6 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Wed, 8 Feb 2023 11:37:20 +0000 Subject: [PATCH 1/3] Enable stubtest for `pyserial` --- stubs/pyserial/@tests/stubtest_allowlist.txt | 10 ++++++---- stubs/pyserial/@tests/stubtest_allowlist_win32.txt | 14 +++++++++++++- stubs/pyserial/METADATA.toml | 4 ---- stubs/pyserial/serial/win32.pyi | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/stubs/pyserial/@tests/stubtest_allowlist.txt b/stubs/pyserial/@tests/stubtest_allowlist.txt index 3575635b7824..f98c2e3d5d6e 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist.txt @@ -28,6 +28,12 @@ serial.urlhandler.protocol_spy.Serial.write # Error: is not present in stub # ============================= +# TODO: work through these and maybe add them +serial.tools.list_ports_linux.SysFS +serial.tools.list_ports_linux.comports +serial.tools.list_ports_windows.SP_DEVINFO_DATA.\w+ +serial.tools.list_ports_windows.GUID.\w+ + # Python 2 compatibility serial.basestring serial.serialutil.basestring @@ -67,7 +73,3 @@ serial.serialutil.SerialBase.setDTR serial.serialutil.SerialBase.setPort serial.serialutil.SerialBase.setRTS serial.serialutil.SerialBase.writeTimeout - -# Private aliases -serial.serialposix.plat -serial.tools.list_ports_posix.plat diff --git a/stubs/pyserial/@tests/stubtest_allowlist_win32.txt b/stubs/pyserial/@tests/stubtest_allowlist_win32.txt index ae6221e4b399..1b9d832f2c42 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_win32.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_win32.txt @@ -2,7 +2,7 @@ # ======================= serial.serialposix # Posix only serial.tools.list_ports_osx # Mac only -serial.tools.list_ports_linux # Linux only +serial.tools.list_ports_posix # Posix only # Error: is inconsistent # ====================== @@ -10,3 +10,15 @@ serial.tools.list_ports_linux # Linux only # but at runtime they are normal arguments that don't have consistent names. serial.serialwin32.Serial.read serial.serialwin32.Serial.write + +# Missing from the stub (TODO: add these) +# ======================================= +serial.win32._SECURITY_ATTRIBUTES.\w+ +serial.win32._OVERLAPPED.\w+ +serial.win32._DCB.\w+ +serial.win32._COMSTAT.\w+ +serial.win32._COMMTIMEOUTS.\w+ +serial.win32.N11_OVERLAPPED4DOLLAR_48E.\w+ +serial.win32.N11_OVERLAPPED4DOLLAR_484DOLLAR_49E.\w+ +serial.win32.CreateEventW +serial.win32.CreateFileW diff --git a/stubs/pyserial/METADATA.toml b/stubs/pyserial/METADATA.toml index 3b70b5e8dcef..23f64cc8ee58 100644 --- a/stubs/pyserial/METADATA.toml +++ b/stubs/pyserial/METADATA.toml @@ -1,10 +1,6 @@ version = "3.5.*" [tool.stubtest] -# Skip stubtest because it crashes with `SystemExit` when trying to import `serial.__main__`. -# This has been fixed in https://github.com/python/mypy/pull/14284. -# TODO: Remove skip once mypy 1.0 is released with the fix. -skip = true ignore_missing_stub = false platforms = ["linux", "win32", "darwin"] extras = ["cp2110"] diff --git a/stubs/pyserial/serial/win32.pyi b/stubs/pyserial/serial/win32.pyi index ddb27cf39736..a06edac4bd6b 100644 --- a/stubs/pyserial/serial/win32.pyi +++ b/stubs/pyserial/serial/win32.pyi @@ -6,7 +6,7 @@ from typing_extensions import TypeAlias if sys.platform == "win32": def is_64bit() -> bool: ... - ULONG_PTR: TypeAlias = c_int64 | c_ulong + ULONG_PTR: c_int64 | c_ulong class _SECURITY_ATTRIBUTES(Structure): ... LPSECURITY_ATTRIBUTES: type[_Pointer[_SECURITY_ATTRIBUTES]] From 0398620a2d4a2233008503533ea6dc07e7949122 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Wed, 8 Feb 2023 11:43:26 +0000 Subject: [PATCH 2/3] stuff --- stubs/pyserial/@tests/stubtest_allowlist.txt | 6 ------ stubs/pyserial/@tests/stubtest_allowlist_darwin.txt | 5 +++++ stubs/pyserial/@tests/stubtest_allowlist_linux.txt | 5 +++++ stubs/pyserial/@tests/stubtest_allowlist_win32.txt | 4 ++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/stubs/pyserial/@tests/stubtest_allowlist.txt b/stubs/pyserial/@tests/stubtest_allowlist.txt index f98c2e3d5d6e..30eebdfe44c2 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist.txt @@ -28,12 +28,6 @@ serial.urlhandler.protocol_spy.Serial.write # Error: is not present in stub # ============================= -# TODO: work through these and maybe add them -serial.tools.list_ports_linux.SysFS -serial.tools.list_ports_linux.comports -serial.tools.list_ports_windows.SP_DEVINFO_DATA.\w+ -serial.tools.list_ports_windows.GUID.\w+ - # Python 2 compatibility serial.basestring serial.serialutil.basestring diff --git a/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt b/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt index 14c220d73f9b..471b964fce0d 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt @@ -15,3 +15,8 @@ serial.serialposix.Serial.read serial.serialposix.Serial.write serial.serialposix.PosixPollSerial.read serial.serialposix.VTIMESerial.read + +# Error: is missing from the stub (intended to be private aliases) +# ================================================================ +serial.tools.list_ports_posix.plat +serial.tools.serialposix.plat diff --git a/stubs/pyserial/@tests/stubtest_allowlist_linux.txt b/stubs/pyserial/@tests/stubtest_allowlist_linux.txt index cf0ee3081188..801a90a2c607 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_linux.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_linux.txt @@ -15,3 +15,8 @@ serial.serialposix.Serial.read serial.serialposix.Serial.write serial.serialposix.PosixPollSerial.read serial.serialposix.VTIMESerial.read + +# Error: is missing from the stub (intended to be private aliases) +# ================================================================ +serial.tools.list_ports_posix.plat +serial.tools.serialposix.plat diff --git a/stubs/pyserial/@tests/stubtest_allowlist_win32.txt b/stubs/pyserial/@tests/stubtest_allowlist_win32.txt index 1b9d832f2c42..fe525e378d1c 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_win32.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_win32.txt @@ -22,3 +22,7 @@ serial.win32.N11_OVERLAPPED4DOLLAR_48E.\w+ serial.win32.N11_OVERLAPPED4DOLLAR_484DOLLAR_49E.\w+ serial.win32.CreateEventW serial.win32.CreateFileW +serial.tools.list_ports_linux.SysFS +serial.tools.list_ports_linux.comports +serial.tools.list_ports_windows.SP_DEVINFO_DATA.\w+ +serial.tools.list_ports_windows.GUID.\w+ From a6372deb541a0ccadb5e04743ba245fdd36f9835 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Wed, 8 Feb 2023 11:49:00 +0000 Subject: [PATCH 3/3] . --- stubs/pyserial/@tests/stubtest_allowlist_darwin.txt | 12 ++++++++---- stubs/pyserial/@tests/stubtest_allowlist_linux.txt | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt b/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt index 471b964fce0d..ac842868cd42 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_darwin.txt @@ -2,7 +2,6 @@ # ======================= serial.serialwin32 # Windows only serial.win32 # Windows only -serial.tools.list_ports_linux # Linux only serial.tools.list_ports_windows # Windows only # Error: is inconsistent @@ -16,7 +15,12 @@ serial.serialposix.Serial.write serial.serialposix.PosixPollSerial.read serial.serialposix.VTIMESerial.read -# Error: is missing from the stub (intended to be private aliases) -# ================================================================ +# Error: is missing from the stub +# =============================== +# TODO: maybe add these +serial.tools.list_ports_linux.SysFS +serial.tools.list_ports_linux.comports + +# intended to be private aliases serial.tools.list_ports_posix.plat -serial.tools.serialposix.plat +serial.serialposix.plat diff --git a/stubs/pyserial/@tests/stubtest_allowlist_linux.txt b/stubs/pyserial/@tests/stubtest_allowlist_linux.txt index 801a90a2c607..5813c930da5f 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_linux.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_linux.txt @@ -19,4 +19,4 @@ serial.serialposix.VTIMESerial.read # Error: is missing from the stub (intended to be private aliases) # ================================================================ serial.tools.list_ports_posix.plat -serial.tools.serialposix.plat +serial.serialposix.plat