From 58ee9c0ae532c3e072c0cac49df3a6718d06379f Mon Sep 17 00:00:00 2001 From: Cebtenzzre Date: Mon, 12 Oct 2020 21:24:09 -0400 Subject: [PATCH] termios: Fix type of tcgetattr and tcsetattr attributes (#4662) Returning a union from tcgetattr forces the caller to use isinstance or a type: ignore comment if they modify the returned list. Return List[Any] instead. The cc field has ints at cc[termios.VTIME] and cc[termios.VMIN] if lflag & termios.ICANON is zero. Change _Attr to allow this. Fixes #4661 --- stdlib/2and3/termios.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/2and3/termios.pyi b/stdlib/2and3/termios.pyi index 779b92626..9eecbf681 100644 --- a/stdlib/2and3/termios.pyi +++ b/stdlib/2and3/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike -from typing import List, Union +from typing import Any, List, Union -_Attr = List[Union[int, List[bytes]]] +_Attr = List[Union[int, List[Union[bytes, int]]]] # TODO constants not really documented B0: int @@ -236,7 +236,7 @@ VWERASE: int XCASE: int XTABS: int -def tcgetattr(fd: FileDescriptorLike) -> _Attr: ... +def tcgetattr(fd: FileDescriptorLike) -> List[Any]: ... def tcsetattr(fd: FileDescriptorLike, when: int, attributes: _Attr) -> None: ... def tcsendbreak(fd: FileDescriptorLike, duration: int) -> None: ... def tcdrain(fd: FileDescriptorLike) -> None: ...