Skip to content

Enable stubtest for pyserial #9692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 8, 2023
Merged
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
4 changes: 0 additions & 4 deletions stubs/pyserial/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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
11 changes: 10 additions & 1 deletion stubs/pyserial/@tests/stubtest_allowlist_darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,3 +14,13 @@ serial.serialposix.Serial.read
serial.serialposix.Serial.write
serial.serialposix.PosixPollSerial.read
serial.serialposix.VTIMESerial.read

# 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.serialposix.plat
5 changes: 5 additions & 0 deletions stubs/pyserial/@tests/stubtest_allowlist_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.serialposix.plat
18 changes: 17 additions & 1 deletion stubs/pyserial/@tests/stubtest_allowlist_win32.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@
# =======================
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
# ======================
# These are positional only argument in the stub because they inherit from io.RawIOBase
# 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
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+
4 changes: 0 additions & 4 deletions stubs/pyserial/METADATA.toml
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion stubs/pyserial/serial/win32.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down