From 27bc5e73bf05cf6ff094c70f0b06d2dbdf5d610c Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 2 Oct 2023 11:39:52 +0100 Subject: [PATCH 1/2] Fix Windows-specific allowlist entries in `_msi`, `msilib`, `selectors` and `subprocess` --- stdlib/_msi.pyi | 2 ++ stdlib/msilib/text.pyi | 2 +- stdlib/selectors.pyi | 13 +++++++------ stdlib/subprocess.pyi | 1 + tests/stubtest_allowlists/win32.txt | 4 ---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/stdlib/_msi.pyi b/stdlib/_msi.pyi index 2fdbdfd0e9f4..ac1cb7fb541d 100644 --- a/stdlib/_msi.pyi +++ b/stdlib/_msi.pyi @@ -1,6 +1,8 @@ import sys if sys.platform == "win32": + class MSIError(Exception): ... + # Actual typename View, not exposed by the implementation class _View: def Execute(self, params: _Record | None = ...) -> None: ... diff --git a/stdlib/msilib/text.pyi b/stdlib/msilib/text.pyi index 1353cf8a2392..441c843ca6cf 100644 --- a/stdlib/msilib/text.pyi +++ b/stdlib/msilib/text.pyi @@ -3,5 +3,5 @@ import sys if sys.platform == "win32": ActionText: list[tuple[str, str, str | None]] UIText: list[tuple[str, str | None]] - + dirname: str tables: list[str] diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index 90a923f09355..43e3b1c507f6 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -59,12 +59,13 @@ class DevpollSelector(BaseSelector): def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... -class KqueueSelector(BaseSelector): - def fileno(self) -> int: ... - def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ... - def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... +if sys.platform != "win32": + class KqueueSelector(BaseSelector): + def fileno(self) -> int: ... + def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ... + def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... + def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class DefaultSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 346e4d5513d8..1013db7ee984 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -2600,6 +2600,7 @@ if sys.platform == "win32": hStdError: Any | None wShowWindow: int lpAttributeList: Mapping[str, Any] + def copy(self) -> STARTUPINFO: ... from _winapi import ( ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS, diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index a556ceacf505..0e7e214e134f 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -4,11 +4,8 @@ locale.nl_langinfo # Function that should be moved to _locale and re-exported c # alias for a class defined elsewhere, # mypy infers the variable has type `(*args) -> DupHandle` but stubtest infers the runtime type as multiprocessing.reduction.AbstractReducer.DupHandle -msilib.text.dirname -selectors.KqueueSelector # Exists at runtime, but missing from stubs -_msi.MSIError _winapi.CreateFileMapping _winapi.MapViewOfFile _winapi.OpenFileMapping @@ -21,7 +18,6 @@ msvcrt.SetErrorMode ssl.SSLSocket.recvmsg ssl.SSLSocket.recvmsg_into ssl.SSLSocket.sendmsg -subprocess.STARTUPINFO.copy winreg.HKEYType.handle _ctypes.FreeLibrary _ctypes.LoadLibrary From d8b054a3e3d01c7184e320f72942aed69ff3ef39 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:40:49 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/_msi.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/_msi.pyi b/stdlib/_msi.pyi index ac1cb7fb541d..160406a6d8d5 100644 --- a/stdlib/_msi.pyi +++ b/stdlib/_msi.pyi @@ -2,7 +2,6 @@ import sys if sys.platform == "win32": class MSIError(Exception): ... - # Actual typename View, not exposed by the implementation class _View: def Execute(self, params: _Record | None = ...) -> None: ...