From a1fe0831334392785a386a10c9131cc9099a7ea2 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 25 Jan 2016 17:01:34 -0800 Subject: [PATCH] Fix class file so it can be used as "with file(...) as f: f.read() # etc." --- stdlib/2.7/__builtin__.pyi | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 77706d489..17a0789d1 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -824,5 +824,29 @@ def cmp(x: Any, y: Any) -> int: ... def execfile(filename: str, globals: Dict[str, Any] = None, locals: Dict[str, Any] = None) -> None: ... -class file(BinaryIO): ... +class file(BinaryIO): + @overload + def __init__(self, file: str, mode: str = 'r', buffering: int = ...) -> None: ... + @overload + def __init__(self, file: unicode, mode: str = 'r', buffering: int = ...) -> None: ... + @overload + def __init__(file: int, mode: str = 'r', buffering: int = ...) -> None: ... + def __iter__(self) -> Iterator[str]: ... + def read(self, n: int = ...) -> str: ... + def __enter__(self) -> BinaryIO: ... + def __exit__(self, typ, exc, tb) -> bool: ... + def flush(self) -> None: ... + def fileno(self) -> int: ... + def isatty(self) -> bool: ... + def close(self) -> None: ... + def readable(self) -> bool: ... + def writable(self) -> bool: ... + def seekable(self) -> bool: ... + def seek(self, offset: int, whence: int = ...) -> None: ... + def tell(self) -> int: ... + def readline(self, limit: int = ...) -> str: ... + def readlines(self, hint: int = ...) -> List[str]: ... + def write(self, data: str) -> None: ... + def writelines(self, data: Iterable[str]) -> None: ... + def truncate(self, pos: int = ...) -> int: ...