mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-18 09:55:59 +08:00
fix integration of io with mypy (#196)
This commit is contained in:
committed by
Guido van Rossum
parent
5c881a6b86
commit
e9efb31aa7
117
stdlib/3/io.pyi
117
stdlib/3/io.pyi
@@ -1,7 +1,7 @@
|
||||
# Stubs for io
|
||||
|
||||
from typing import (
|
||||
List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple
|
||||
List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Any, IO
|
||||
)
|
||||
import builtins
|
||||
import codecs
|
||||
@@ -47,7 +47,7 @@ class IOBase:
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
def writelines(self, lines: bytes) -> None: ...
|
||||
def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def readline(self, size: int = ...) -> bytes: ...
|
||||
def __del__(self) -> None: ...
|
||||
@@ -68,7 +68,7 @@ class RawIOBase(IOBase):
|
||||
def read(self, n: int = ...) -> Optional[bytes]: ... # type: ignore
|
||||
|
||||
class BufferedIOBase(IOBase):
|
||||
def detach(self) -> 'RawIOBase': ...
|
||||
def detach(self) -> RawIOBase: ...
|
||||
def readinto(self, b: bytearray) -> int: ...
|
||||
def write(self, b: Union[bytes, bytearray]) -> int: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
@@ -94,12 +94,53 @@ class FileIO(RawIOBase):
|
||||
def __init__(self, name: Union[str, bytes, int], # type: ignore
|
||||
mode: str = ..., closefd: bool = ...) -> None: ...
|
||||
|
||||
|
||||
class BytesIO(BufferedIOBase):
|
||||
# TODO should extend from BufferedIOBase
|
||||
class BytesIO(BinaryIO):
|
||||
def __init__(self, initial_bytes: bytes = ...) -> None: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
if sys.version_info >= (3, 2):
|
||||
def getbuffer(self) -> memoryview: ...
|
||||
# copied from IOBase
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def __next__(self) -> bytes: ...
|
||||
def __enter__(self) -> 'BytesIO': ...
|
||||
def __exit__(self, t: type = None, value: BaseException = None,
|
||||
traceback: Any = None) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def readable(self) -> bool: ...
|
||||
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: ...
|
||||
# TODO should be the next line instead
|
||||
# def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...
|
||||
def writelines(self, lines: Any) -> None: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def readline(self, size: int = ...) -> bytes: ...
|
||||
def __del__(self) -> None: ...
|
||||
else:
|
||||
def readline(self, limit: int = ...): ... # type: ignore
|
||||
if sys.version_info >= (3, 2):
|
||||
closed = ... # type: bool
|
||||
else:
|
||||
def closed(self) -> bool: ... # type: ignore
|
||||
# copied from BufferedIOBase
|
||||
def detach(self) -> RawIOBase: ...
|
||||
def readinto(self, b: bytearray) -> int: ...
|
||||
def write(self, b: Union[bytes, bytearray]) -> Optional[int]: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def readinto1(self, b: bytearray) -> int: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def read(self, size: Optional[int] = ...) -> bytes: ...
|
||||
def read1(self, size: int = ...) -> bytes: ...
|
||||
else:
|
||||
def read(self, n: Optional[int] = ...) -> bytes: ... # type: ignore
|
||||
def read1(self, n: int = ...) -> bytes: ... # type: ignore
|
||||
|
||||
class BufferedReader(BufferedIOBase):
|
||||
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
|
||||
@@ -143,18 +184,64 @@ class TextIOBase(IOBase):
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
|
||||
class TextIOWrapper(TextIOBase):
|
||||
# TODO should extend from TextIOBase
|
||||
class TextIOWrapper(TextIO):
|
||||
line_buffering = ... # type: bool
|
||||
if sys.version_info >= (3, 3):
|
||||
def __init__(self, buffer: BufferedIOBase, encoding: str = ...,
|
||||
errors: Optional[str] = ..., newline: Optional[str] = ...,
|
||||
line_buffering: bool = ..., write_through: bool = ...) \
|
||||
-> None: ...
|
||||
# TODO uncomment after fixing mypy about using write_through
|
||||
#if sys.version_info >= (3, 3):
|
||||
# def __init__(self, buffer: IO[bytes], encoding: str = ...,
|
||||
# errors: Optional[str] = ..., newline: Optional[str] = ...,
|
||||
# line_buffering: bool = ..., write_through: bool = ...) \
|
||||
# -> None: ...
|
||||
#else:
|
||||
# def __init__(self, buffer: IO[bytes], # type: ignore
|
||||
# encoding: str = ..., errors: Optional[str] = ...,
|
||||
# newline: Optional[str] = ..., line_buffering: bool = ...) \
|
||||
# -> None: ...
|
||||
def __init__(self, buffer: IO[bytes], encoding: str = ...,
|
||||
errors: Optional[str] = ..., newline: Optional[str] = ...,
|
||||
line_buffering: bool = ..., write_through: bool = ...) \
|
||||
-> None: ...
|
||||
# copied from IOBase
|
||||
def __exit__(self, t: type = None, value: BaseException = None,
|
||||
traceback: Any = None) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def readable(self) -> bool: ...
|
||||
def readlines(self, hint: int = ...) -> List[str]: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
# TODO should be the next line instead
|
||||
# def writelines(self, lines: List[str]) -> None: ...
|
||||
def writelines(self, lines: Any) -> None: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def __del__(self) -> None: ...
|
||||
if sys.version_info >= (3, 2):
|
||||
closed = ... # type: bool
|
||||
else:
|
||||
def __init__(self, buffer: BufferedIOBase, # type: ignore
|
||||
encoding: str = ..., errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ..., line_buffering: bool = ...) \
|
||||
-> None: ...
|
||||
def closed(self) -> bool: ... # type: ignore
|
||||
# copied from TextIOBase
|
||||
encoding = ... # type: str
|
||||
errors = ... # type: Optional[str]
|
||||
newlines = ... # type: Union[str, Tuple[str, ...], None]
|
||||
def __iter__(self) -> Iterator[str]: ... # type: ignore
|
||||
def __next__(self) -> str: ... # type: ignore
|
||||
def __enter__(self) -> 'TextIO': ...
|
||||
def detach(self) -> IOBase: ...
|
||||
def write(self, s: str) -> int: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def readline(self, size: int = ...) -> str: ... # type: ignore
|
||||
def read(self, size: Optional[int] = ...) -> str: ...
|
||||
elif sys.version_info >= (3, 2):
|
||||
def readline(self, limit: int = ...) -> str: ... # type: ignore
|
||||
else:
|
||||
def readline(self) -> str: ... # type: ignore
|
||||
if sys.version_info >= (3, 2):
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
|
||||
class StringIO(TextIOWrapper):
|
||||
def __init__(self, initial_value: str = ...,
|
||||
|
||||
Reference in New Issue
Block a user