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
This commit is contained in:
Cebtenzzre
2020-10-12 21:24:09 -04:00
committed by GitHub
parent 86ca46fa0a
commit 58ee9c0ae5

View File

@@ -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: ...