From bf501353a0668369e53cc1bc97250bb14f61a09e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 22 Mar 2016 12:21:17 -0700 Subject: [PATCH] Hopeful fix for fcntl stubs -- change return values back to Any. --- stdlib/2.7/fcntl.pyi | 12 +++++++----- stdlib/3/fcntl.pyi | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/stdlib/2.7/fcntl.pyi b/stdlib/2.7/fcntl.pyi index 5a1a5368f..5e7da7fef 100644 --- a/stdlib/2.7/fcntl.pyi +++ b/stdlib/2.7/fcntl.pyi @@ -1,4 +1,4 @@ -from typing import Union +from typing import Any, Union import io FASYNC = ... # type: int @@ -74,12 +74,14 @@ LOCK_WRITE = ... # type: int _ANYFILE = Union[int, io.IOBase] -def fcntl(fd: _ANYFILE, op: int, arg: Union[int, str] = ...) -> Union[int, str]: ... +# TODO All these return either int or bytes depending on the value of +# cmd (not on the type of arg). +def fcntl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...) -> Any: ... # TODO: arg: int or read-only buffer interface or read-write buffer interface -def ioctl(fd: _ANYFILE, op: int, arg: Union[int, str] = ..., - mutate_flag: bool = ...) -> Union[int, str]: ... +def ioctl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ..., + mutate_flag: bool = ...) -> Any: ... def flock(fd: _ANYFILE, op: int) -> None: ... def lockf(fd: _ANYFILE, op: int, length: int = ..., start: int = ..., - whence: int = ...) -> Union[int, str]: ... + whence: int = ...) -> Any: ... diff --git a/stdlib/3/fcntl.pyi b/stdlib/3/fcntl.pyi index ecf066664..a50fa0d87 100644 --- a/stdlib/3/fcntl.pyi +++ b/stdlib/3/fcntl.pyi @@ -77,18 +77,20 @@ LOCK_WRITE = ... # type: int _AnyFile = Union[int, IO[Any]] +# TODO All these return either int or bytes depending on the value of +# cmd (not on the type of arg). def fcntl(fd: _AnyFile, cmd: int, - arg: Union[int, bytes] = ...) -> Union[int, bytes]: ... + arg: Union[int, bytes] = ...) -> Any: ... # TODO This function accepts any object supporting a buffer interface, # as arg, is there a better way to express this than bytes? def ioctl(fd: _AnyFile, request: int, arg: Union[int, bytes] = ..., - mutate_flag: bool = ...) -> Union[int, bytes]: ... + mutate_flag: bool = ...) -> Any: ... def flock(fd: _AnyFile, operation: int) -> None: ... def lockf(fd: _AnyFile, cmd: int, len: int = ..., start: int = ..., - whence: int = ...) -> Union[int, bytes]: ... + whence: int = ...) -> Any: ...