From 6b7be8055ae0c60fd0360a4867d5f71a72a3dc0d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 5 Dec 2021 18:18:56 +0000 Subject: [PATCH 1/5] initial commit --- stdlib/os/__init__.pyi | 25 ++++++++++++++--------- tests/stubtest_allowlists/win32-py310.txt | 1 - tests/stubtest_allowlists/win32-py39.txt | 1 - tests/stubtest_allowlists/win32.txt | 3 --- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index fc0af0d47100..34033d1aed8d 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -20,6 +20,7 @@ from typing import ( AnyStr, BinaryIO, Callable, + ClassVar, Generic, Iterable, Iterator, @@ -417,6 +418,17 @@ def getppid() -> int: ... def strerror(__code: int) -> str: ... def umask(__mask: int) -> int: ... +@final +class uname_result(NamedTuple): + sysname: str + nodename: str + release: str + version: str + machine: str + n_fields: ClassVar[int] + n_sequence_fields: ClassVar[int] + n_unnamed_fields: ClassVar[int] + if sys.platform != "win32": def ctermid() -> str: ... def getegid() -> int: ... @@ -447,13 +459,6 @@ if sys.platform != "win32": def getsid(__pid: int) -> int: ... def setsid() -> None: ... def setuid(__uid: int) -> None: ... - @final - class uname_result(NamedTuple): - sysname: str - nodename: str - release: str - version: str - machine: str def uname() -> uname_result: ... @overload @@ -469,7 +474,7 @@ if sys.platform != "win32": def putenv(__name: bytes | str, __value: bytes | str) -> None: ... -if sys.platform != "win32": +if sys.platform != "win32" or sys.version_info >= (3, 9): def unsetenv(__name: bytes | str) -> None: ... _Opener = Callable[[str, int], int] @@ -563,7 +568,9 @@ else: def dup2(fd: int, fd2: int, inheritable: bool = ...) -> None: ... def fstat(fd: int) -> stat_result: ... +def ftruncate(__fd: int, __length: int) -> None: ... def fsync(fd: FileDescriptorLike) -> None: ... +def isatty(__fd: int) -> bool: ... def lseek(__fd: int, __position: int, __how: int) -> int: ... def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: int | None = ...) -> int: ... def pipe() -> tuple[int, int]: ... @@ -577,10 +584,8 @@ if sys.platform != "win32": def fdatasync(fd: FileDescriptorLike) -> None: ... # Unix only, not Mac def fpathconf(__fd: int, __name: str | int) -> int: ... def fstatvfs(__fd: int) -> statvfs_result: ... - def ftruncate(__fd: int, __length: int) -> None: ... def get_blocking(__fd: int) -> bool: ... def set_blocking(__fd: int, __blocking: bool) -> None: ... - def isatty(__fd: int) -> bool: ... def lockf(__fd: int, __command: int, __length: int) -> None: ... def openpty() -> tuple[int, int]: ... # some flavors of Unix if sys.platform != "darwin": diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index 392071a0bc17..c57296600b9e 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -16,6 +16,5 @@ asyncio.IocpProactor.sendto asyncio.windows_events.IocpProactor.recvfrom asyncio.windows_events.IocpProactor.sendto msvcrt.GetErrorMode -os.unsetenv socket.MsgFlag.MSG_ERRQUEUE subprocess.STARTUPINFO.copy diff --git a/tests/stubtest_allowlists/win32-py39.txt b/tests/stubtest_allowlists/win32-py39.txt index 65ee9f2752fd..ec7248fefe36 100644 --- a/tests/stubtest_allowlists/win32-py39.txt +++ b/tests/stubtest_allowlists/win32-py39.txt @@ -21,6 +21,5 @@ asyncio.IocpProactor.recvfrom asyncio.IocpProactor.sendto asyncio.windows_events.IocpProactor.recvfrom asyncio.windows_events.IocpProactor.sendto -os.unsetenv socket.MsgFlag.MSG_ERRQUEUE subprocess.STARTUPINFO.copy diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 962c05a2e151..f2663110e0da 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -46,12 +46,9 @@ distutils.msvccompiler.MSVCCompiler.manifest_get_embed_info distutils.msvccompiler.MSVCCompiler.manifest_setup_ldargs distutils.msvccompiler.OldMSVCCompiler msvcrt.SetErrorMode -os.ftruncate os.get_handle_inheritable -os.isatty os.set_handle_inheritable os.statvfs_result -os.uname_result signal.Signals.CTRL_BREAK_EVENT signal.Signals.CTRL_C_EVENT socket.MsgFlag.MSG_BCAST From f9f2659e8cea772b13e044e1e90909a4fb43ed32 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 5 Dec 2021 18:22:22 +0000 Subject: [PATCH 2/5] Second commit --- tests/stubtest_allowlists/darwin.txt | 3 --- tests/stubtest_allowlists/linux.txt | 3 --- 2 files changed, 6 deletions(-) diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index 72e3a0977144..a22f178e129e 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -57,9 +57,6 @@ grp.struct_group.n_unnamed_fields mimetypes.MimeTypes.read_windows_registry os.ST_NOSUID os.ST_RDONLY -(os|posix).uname_result.n_fields -(os|posix).uname_result.n_sequence_fields -(os|posix).uname_result.n_unnamed_fields posix.chflags posix.dup2 posix.lchflags diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index 57b2e6f019b9..1bcea1d4934f 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -62,9 +62,6 @@ mimetypes.MimeTypes.read_windows_registry (os|posix).sched_param.n_fields (os|posix).sched_param.n_sequence_fields (os|posix).sched_param.n_unnamed_fields -(os|posix).uname_result.n_fields -(os|posix).uname_result.n_sequence_fields -(os|posix).uname_result.n_unnamed_fields (os|posix).waitid_result.n_fields (os|posix).waitid_result.n_sequence_fields (os|posix).waitid_result.n_unnamed_fields From a0172ebccaa53b3d34603d47c772398443127a48 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Dec 2021 18:28:02 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/os/__init__.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 34033d1aed8d..05733cf0ca77 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -417,7 +417,6 @@ def getpid() -> int: ... def getppid() -> int: ... def strerror(__code: int) -> str: ... def umask(__mask: int) -> int: ... - @final class uname_result(NamedTuple): sysname: str From 50498a8357cbb78af1b8ab8a9b52deabc21ca56b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 5 Dec 2021 18:34:19 +0000 Subject: [PATCH 4/5] For some reason all entries in win32-py39 were given twice? --- tests/stubtest_allowlists/win32-py39.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/stubtest_allowlists/win32-py39.txt b/tests/stubtest_allowlists/win32-py39.txt index ec7248fefe36..b351653efc9c 100644 --- a/tests/stubtest_allowlists/win32-py39.txt +++ b/tests/stubtest_allowlists/win32-py39.txt @@ -1,17 +1,4 @@ -# Missing from stubs, found by removing --ignore-missing-stub -_winapi.CreateFileMapping -_winapi.MapViewOfFile -_winapi.OpenFileMapping -_winapi.VirtualQuerySize -asyncio.IocpProactor.recvfrom -asyncio.IocpProactor.sendto -asyncio.windows_events.IocpProactor.recvfrom -asyncio.windows_events.IocpProactor.sendto -os.unsetenv -socket.MsgFlag.MSG_ERRQUEUE -subprocess.STARTUPINFO.copy - # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile From 58f60870081e9772e412fa185d6215bfaf011d37 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 5 Dec 2021 19:25:12 +0000 Subject: [PATCH 5/5] Address review --- stdlib/os/__init__.pyi | 4 ---- tests/stubtest_allowlists/py3_common.txt | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 05733cf0ca77..94d56a16757c 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -20,7 +20,6 @@ from typing import ( AnyStr, BinaryIO, Callable, - ClassVar, Generic, Iterable, Iterator, @@ -424,9 +423,6 @@ class uname_result(NamedTuple): release: str version: str machine: str - n_fields: ClassVar[int] - n_sequence_fields: ClassVar[int] - n_unnamed_fields: ClassVar[int] if sys.platform != "win32": def ctermid() -> str: ... diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 820bf84afa07..55a8dfe9bc73 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -580,6 +580,9 @@ multiprocessing.synchronize.Semaphore.get_value (os|posix).times_result.n_fields (os|posix).times_result.n_sequence_fields (os|posix).times_result.n_unnamed_fields +(os|posix).uname_result.n_fields +(os|posix).uname_result.n_sequence_fields +(os|posix).uname_result.n_unnamed_fields pickle.Pickler.memo pickle.Unpickler.memo pipes.Template.makepipeline