From 4dad5311d56e0b90ab82756a8c2a9ce645a788b1 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 27 Sep 2023 12:15:32 +0300 Subject: [PATCH] Update `tty` to python 3.12 (#10784) --- 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..5a63dbf2dc53 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -1,9 +1,11 @@ import sys -from typing import IO +from typing import IO, Any 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] @@ -17,3 +19,10 @@ 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): + # It is: `list[int, int, int, int, int, int, list[str]] + _Mode: TypeAlias = list[Any] + + def cfmakeraw(mode: _Mode) -> None: ... + 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,