mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Make io._IOBase and its descendents concrete. (#1172)
This solves the issue with instantiating gzip.GzipFile() mentioned at https://github.com/python/typeshed/pull/1160#issuecomment-294534004
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, BinaryIO, Optional, Iterable, Tuple, List, Union
|
||||
from typing import Any, BinaryIO, IO, Iterable, Iterator, List, Optional, Type, Tuple, Union
|
||||
|
||||
DEFAULT_BUFFER_SIZE = ... # type: int
|
||||
|
||||
@@ -14,6 +14,28 @@ class _IOBase(BinaryIO):
|
||||
def _checkReadable(self) -> None: ...
|
||||
def _checkSeekable(self) -> None: ...
|
||||
def _checkWritable(self) -> None: ...
|
||||
# All these methods are concrete here (you can instantiate this)
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def read(self, n: int = ...) -> bytes: ...
|
||||
def readable(self) -> bool: ...
|
||||
def readline(self, limit: int = ...) -> bytes: ...
|
||||
def readlines(self, hint: int = ...) -> list[bytes]: ...
|
||||
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: bytes) -> int: ...
|
||||
def writelines(self, lines: Iterable[bytes]) -> None: ...
|
||||
def next(self) -> bytes: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def __enter__(self) -> '_IOBase': ...
|
||||
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException],
|
||||
# TODO: traceback should be TracebackType but that's defined in types
|
||||
traceback: Optional[Any]) -> bool: ...
|
||||
|
||||
class _BufferedIOBase(_IOBase):
|
||||
def read1(self, n: int) -> str: ...
|
||||
|
||||
@@ -101,4 +101,4 @@ class TextIOWrapper(TextIO):
|
||||
def __enter__(self) -> StringIO: ...
|
||||
def __exit__(self, type, value, traceback) -> bool: ...
|
||||
|
||||
class BufferedIOBase(IOBase): ...
|
||||
class BufferedIOBase(_io._BufferedIOBase, IOBase): ...
|
||||
|
||||
Reference in New Issue
Block a user