Fix abstract classes in 2.7 (#2247)

Part of #1476.
This commit is contained in:
Jelle Zijlstra
2018-06-17 09:21:17 -07:00
committed by Ivan Levkivskyi
parent 6b36b1befe
commit 8084dc1c1f
6 changed files with 55 additions and 34 deletions

View File

@@ -1,17 +1,6 @@
# Stubs for tempfile
# Ron Murawski <ron@horizonchess.com>
# based on http: //docs.python.org/3.3/library/tempfile.html
# Adapted for Python 2.7 by Michal Pokorny
# TODO: Don't use basestring. Use Union[str, bytes] or AnyStr for arguments.
# Avoid using Union[str, bytes] for return values, as it implies that
# an isinstance() check will often be required, which is inconvenient.
from typing import Tuple, IO, Union, AnyStr, Any, overload, Iterator, List, Type, Optional
import thread
import random
from typing import Tuple, IO, Union, AnyStr, Any, overload, Iterator, List, Iterable, Optional
from thread import LockType
from random import Random
TMP_MAX = ... # type: int
tempdir = ... # type: str
@@ -19,28 +8,46 @@ template = ... # type: str
_name_sequence = ... # type: Optional[_RandomNameSequence]
class _RandomNameSequence:
_rng = ... # type: random.Random
_rng_pid = ... # type: int
characters = ... # type: str
mutex = ... # type: thread.LockType
rng = ... # type: random.Random
def __iter__(self) -> "_RandomNameSequence": ...
characters: str = ...
mutex: LockType
@property
def rng(self) -> Random: ...
def __iter__(self) -> _RandomNameSequence: ...
def next(self) -> str: ...
# from os.path:
def normcase(self, path: AnyStr) -> AnyStr: ...
class _TemporaryFileWrapper(IO[str]):
close_called = ... # type: bool
delete = ... # type: bool
file = ... # type: IO
name = ... # type: Any
def __init__(self, file: IO, name, delete: bool = ...) -> None: ...
delete: bool
file: IO
name: Any
def __init__(self, file: IO, name: Any, delete: bool = ...) -> None: ...
def __del__(self) -> None: ...
def __enter__(self) -> "_TemporaryFileWrapper": ...
def __enter__(self) -> _TemporaryFileWrapper: ...
def __exit__(self, exc, value, tb) -> bool: ...
def __getattr__(self, name: unicode) -> Any: ...
def close(self) -> None: ...
def unlink(self, path: unicode) -> None: ...
# These methods don't exist directly on this object, but
# are delegated to the underlying IO object through __getattr__.
# We need to add them here so that this class is concrete.
def __iter__(self) -> Iterator[str]: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def next(self) -> str: ...
def read(self, n: int = ...) -> str: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def write(self, s: str) -> int: ...
def writelines(self, lines: Iterable[str]) -> None: ...
# TODO text files