Skip to content

Commit 58ee9c0

Browse files
authored
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
1 parent 86ca46f commit 58ee9c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

stdlib/2and3/termios.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import FileDescriptorLike
2-
from typing import List, Union
2+
from typing import Any, List, Union
33

4-
_Attr = List[Union[int, List[bytes]]]
4+
_Attr = List[Union[int, List[Union[bytes, int]]]]
55

66
# TODO constants not really documented
77
B0: int
@@ -236,7 +236,7 @@ VWERASE: int
236236
XCASE: int
237237
XTABS: int
238238

239-
def tcgetattr(fd: FileDescriptorLike) -> _Attr: ...
239+
def tcgetattr(fd: FileDescriptorLike) -> List[Any]: ...
240240
def tcsetattr(fd: FileDescriptorLike, when: int, attributes: _Attr) -> None: ...
241241
def tcsendbreak(fd: FileDescriptorLike, duration: int) -> None: ...
242242
def tcdrain(fd: FileDescriptorLike) -> None: ...

0 commit comments

Comments
 (0)