From 43257a3ea158bb8ed9b1e6815d137bc34cb2bda1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 27 Sep 2023 10:19:10 +0300 Subject: [PATCH 1/3] Update `tty` to python 3.12 --- stdlib/tty.pyi | 11 ++++++++++- tests/stubtest_allowlists/darwin-py312.txt | 3 --- tests/stubtest_allowlists/linux-py312.txt | 3 --- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stdlib/tty.pyi b/stdlib/tty.pyi index 43f2e1cf9087..cba7f840f3c8 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO +from typing import IO, Any from typing_extensions import TypeAlias if sys.platform != "win32": @@ -17,3 +17,12 @@ if sys.platform != "win32": CC: int def setraw(fd: _FD, when: int = 2) -> None: ... def setcbreak(fd: _FD, when: int = 2) -> None: ... + + if sys.version_info >= (3, 12): + __all__ += ["cfmakeraw", "cfmakecbreak"] + + # It is: `list[int, int, int, int, int, int, list[str]] + _Mode: TypeAlias = list[Any] + + def cfmakeraw(mode: _Mode): + def cfmakecbreak(mode: _Mode) -> None: ... diff --git a/tests/stubtest_allowlists/darwin-py312.txt b/tests/stubtest_allowlists/darwin-py312.txt index fb9f9a48ffef..e50d2facc6f8 100644 --- a/tests/stubtest_allowlists/darwin-py312.txt +++ b/tests/stubtest_allowlists/darwin-py312.txt @@ -4,9 +4,6 @@ _curses.window.get_wch _posixsubprocess.fork_exec curses.unget_wch curses.window.get_wch -tty.__all__ -tty.cfmakecbreak -tty.cfmakeraw xxlimited.Xxo.x_exports (dbm.gnu)? diff --git a/tests/stubtest_allowlists/linux-py312.txt b/tests/stubtest_allowlists/linux-py312.txt index bf2f40815bf8..9eb8adbd896a 100644 --- a/tests/stubtest_allowlists/linux-py312.txt +++ b/tests/stubtest_allowlists/linux-py312.txt @@ -8,9 +8,6 @@ mmap.MAP_STACK resource.prlimit signal.sigtimedwait signal.sigwaitinfo -tty.__all__ -tty.cfmakecbreak -tty.cfmakeraw xxlimited.Xxo.x_exports # Exists on some Linux builds, and is documented, From 1f910105de9e4f42f742d0559250612314500efb Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 27 Sep 2023 10:26:10 +0300 Subject: [PATCH 2/3] Typo --- stdlib/tty.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tty.pyi b/stdlib/tty.pyi index cba7f840f3c8..9642ccf8faa7 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -24,5 +24,5 @@ if sys.platform != "win32": # It is: `list[int, int, int, int, int, int, list[str]] _Mode: TypeAlias = list[Any] - def cfmakeraw(mode: _Mode): + def cfmakeraw(mode: _Mode) -> None: ... def cfmakecbreak(mode: _Mode) -> None: ... From 6cf3ef8fc554b6cc89a7c3cc973ac265f48b4915 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 27 Sep 2023 11:53:59 +0300 Subject: [PATCH 3/3] Address review --- stdlib/tty.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/tty.pyi b/stdlib/tty.pyi index 9642ccf8faa7..5a63dbf2dc53 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -4,6 +4,8 @@ from typing_extensions import TypeAlias if sys.platform != "win32": __all__ = ["setraw", "setcbreak"] + if sys.version_info >= (3, 12): + __all__ += ["cfmakeraw", "cfmakecbreak"] _FD: TypeAlias = int | IO[str] @@ -19,8 +21,6 @@ if sys.platform != "win32": def setcbreak(fd: _FD, when: int = 2) -> None: ... if sys.version_info >= (3, 12): - __all__ += ["cfmakeraw", "cfmakecbreak"] - # It is: `list[int, int, int, int, int, int, list[str]] _Mode: TypeAlias = list[Any]