mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
a better definition for io.IOBase (#1160)
* a better definition for io.IOBase * move BinaryIO superclass into _io._IOBase * remove write() from _TextIOBase
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Optional, Iterable, Tuple, List, Union
|
||||
from typing import Any, BinaryIO, Optional, Iterable, Tuple, List, Union
|
||||
|
||||
DEFAULT_BUFFER_SIZE = ... # type: int
|
||||
|
||||
@@ -9,29 +9,11 @@ class BlockingIOError(IOError):
|
||||
class UnsupportedOperation(ValueError, IOError): ...
|
||||
|
||||
|
||||
class _IOBase(object):
|
||||
closed = ... # type: bool
|
||||
def __enter__(self) -> "_IOBase": ...
|
||||
def __exit__(self, type, value, traceback) -> bool: ...
|
||||
def __iter__(self) -> "_IOBase": ...
|
||||
class _IOBase(BinaryIO):
|
||||
def _checkClosed(self) -> None: ...
|
||||
def _checkReadable(self) -> None: ...
|
||||
def _checkSeekable(self) -> None: ...
|
||||
def _checkWritable(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def next(self) -> 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 = ...) -> None: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: int = ...) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
def writelines(self, lines: Iterable[str]) -> None: ...
|
||||
|
||||
class _BufferedIOBase(_IOBase):
|
||||
def read1(self, n: int) -> str: ...
|
||||
@@ -87,8 +69,6 @@ class _TextIOBase(_IOBase):
|
||||
newlines = ... # type: Union[str, unicode]
|
||||
encoding = ... # type: Optional[str]
|
||||
def read(self, n: int = ...) -> str: ...
|
||||
def write(self) -> None:
|
||||
raise UnsupportedOperation
|
||||
def detach(self) -> None:
|
||||
raise UnsupportedOperation
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# Only a subset of functionality is included.
|
||||
|
||||
from typing import List, BinaryIO, TextIO, IO, overload, Iterator, Iterable, Any, Union, Optional
|
||||
import _io
|
||||
|
||||
DEFAULT_BUFFER_SIZE = 0
|
||||
|
||||
@@ -13,9 +14,7 @@ def open(file: Union[str, unicode, int],
|
||||
errors: unicode = ..., newline: unicode = ...,
|
||||
closefd: bool = ...) -> IO[Any]: ...
|
||||
|
||||
class IOBase:
|
||||
# TODO
|
||||
...
|
||||
class IOBase(_io._IOBase): ...
|
||||
|
||||
class BytesIO(BinaryIO):
|
||||
def __init__(self, initial_bytes: str = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user