Hopeful fix for fcntl stubs -- change return values back to Any.

This commit is contained in:
Guido van Rossum
2016-03-22 12:21:17 -07:00
parent 53e2d43f37
commit bf501353a0
2 changed files with 12 additions and 8 deletions

View File

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

View File

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