Skip to content

improve io #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions stdlib/3.3/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ class ElementTree:

def register_namespace(prefix: str, uri: str) -> None: ...
def tostring(element: Element, encoding: str=..., method: str=...) -> str: ...

class _ListDataStream(io.BufferedIOBase):
lst = ... # type: List[str]
def __init__(self, lst) -> None: ...
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
def write(self, b: str) -> None: ...
def tell(self) -> int: ...

def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[str]: ...
def dump(elem: Element) -> None: ...
def parse(source: _file_or_filename, parser: 'XMLParser'=...) -> ElementTree: ...
Expand Down
9 changes: 0 additions & 9 deletions stdlib/3.4/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ class ElementTree:

def register_namespace(prefix: str, uri: str) -> None: ...
def tostring(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> str: ...

class _ListDataStream(io.BufferedIOBase):
lst = ... # type: List[str]
def __init__(self, lst) -> None: ...
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
def write(self, b: str) -> None: ...
def tell(self) -> int: ...

def tostringlist(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> List[str]: ...
def dump(elem: Element) -> None: ...
def parse(source: _file_or_filename, parser: 'XMLParser'=...) -> ElementTree: ...
Expand Down
9 changes: 0 additions & 9 deletions stdlib/3.5/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ class ElementTree:

def register_namespace(prefix: str, uri: str) -> None: ...
def tostring(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> str: ...

class _ListDataStream(io.BufferedIOBase):
lst = ... # type: List[str]
def __init__(self, lst) -> None: ...
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
def write(self, b: str) -> None: ...
def tell(self) -> int: ...

def tostringlist(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> List[str]: ...
def dump(elem: Element) -> None: ...
def parse(source: _file_or_filename, parser: 'XMLParser'=...) -> ElementTree: ...
Expand Down
48 changes: 0 additions & 48 deletions stdlib/3/_io.pyi

This file was deleted.

258 changes: 136 additions & 122 deletions stdlib/3/io.pyi
Original file line number Diff line number Diff line change
@@ -1,150 +1,164 @@
# Stubs for io

# Based on http://docs.python.org/3.2/library/io.html

from typing import List, BinaryIO, TextIO, IO, overload, Iterator, Iterable, Any
from typing import (
List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple
)
import builtins
import codecs
import _io
import sys
from types import TracebackType

DEFAULT_BUFFER_SIZE = ... # type: int

DEFAULT_BUFFER_SIZE = 0 # type: int
SEEK_SET = ... # type: int
SEEK_CUR = ... # type: int
SEEK_END = ... # type: int

open = builtins.open

class BlockingIOError(OSError): ...
class UnsupportedOperation(ValueError, OSError): ...

class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
newlines = ... # type: Any
def __init__(self, *args, **kwargs) -> None: ...
def decode(self, input, final=...): ...
def getstate(self): ...
def reset(self): ...
def setstate(self, state): ...

class IOBase(_io._IOBase): ...
class RawIOBase(_io._RawIOBase, IOBase): ...
class BufferedIOBase(_io._BufferedIOBase, IOBase): ...
class TextIOBase(_io._TextIOBase, IOBase): ...

class FileIO(_io._RawIOBase):
closefd = ... # type: Any
mode = ... # type: Any
def __init__(self, name, mode=..., closefd=..., opener=...) -> None: ...
def readinto(self, b): ...
def write(self, b): ...

class BufferedReader(_io._BufferedIOBase):
mode = ... # type: Any
name = ... # type: Any
raw = ... # type: Any
def __init__(self, raw, buffer_size=...) -> None: ...
def peek(self, size: int = ...): ...

class BufferedWriter(_io._BufferedIOBase):
mode = ... # type: Any
name = ... # type: Any
raw = ... # type: Any
def __init__(self, raw, buffer_size=...) -> None: ...

class BufferedRWPair(_io._BufferedIOBase):
def __init__(self, reader, writer, buffer_size=...) -> None: ...
def peek(self, size: int = ...): ...

class BufferedRandom(_io._BufferedIOBase):
mode = ... # type: Any
name = ... # type: Any
raw = ... # type: Any
def __init__(self, raw, buffer_size=...) -> None: ...
def peek(self, size: int = ...): ...

class BytesIO(BinaryIO):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
# TODO getbuffer
# TODO see comments in BinaryIO for missing functionality
# FIXME when mypy handle condtional, we can uncomment the next block and remove
# the temporary fix
#if sys.version_info >= (3, 3):
# BlockingIOError = BlockingIOError
# class UnsupportedOperation(OSError, ValueError): ...
#else:
# class BlockingIOError(IOError):
# characters_written = ... # type: int
# class UnsupportedOperation(IOError, ValueError): ...
class BlockingIOError(OSError):
characters_written = ... # type: int
class UnsupportedOperation(OSError, ValueError): ...


class IOBase:
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> 'IOBase': ...
def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception],
exc_tb: Optional[TracebackType]) -> bool: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
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: int = ...) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
@overload
def write(self, s: bytes) -> int: ...
@overload
def write(self, s: bytearray) -> int: ...
def writelines(self, lines: Iterable[bytes]) -> None: ...
def writelines(self, lines: bytes) -> None: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> bytes: ...
def __del__(self) -> None: ...
else:
def readline(self, limit: int = ...) -> bytes: ... # type: ignore
if sys.version_info >= (3, 2):
closed = ... # type: bool
else:
def closed(self) -> bool: ... # type: ignore

class RawIOBase(IOBase):
def readall(self) -> bytes: ...
def readinto(self, b: bytearray) -> Optional[int]: ...
def write(self, b: Union[bytes, bytearray]) -> Optional[int]: ...
if sys.version_info >= (3, 4):
def read(self, size: int = ...) -> Optional[bytes]: ...
else:
def read(self, n: int = ...) -> Optional[bytes]: ... # type: ignore

class BufferedIOBase(IOBase):
def detach(self) -> 'RawIOBase': ...
def readinto(self, b: bytearray) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> 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 FileIO(RawIOBase):
mode = ... # type: str
name = ... # type: Union[int, str]
if sys.version_info >= (3, 3):
def __init__(self, name: Union[str, bytes, int], mode: str = ...,
closefd: bool = ...,
opener: Optional[
Callable[[Union[int, str], str], int]] = ...) \
-> None: ...
else:
def __init__(self, name: Union[str, bytes, int], # type: ignore
mode: str = ..., closefd: bool = ...) -> None: ...


class BytesIO(BufferedIOBase):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
def getvalue(self) -> bytes: ...
def read1(self) -> str: ...

def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> 'BytesIO': ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...

class StringIO(TextIO):
def __init__(self, initial_value: str = ...,
newline: str = ...) -> None: ...
# TODO see comments in BinaryIO for missing functionality
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def fileno(self) -> int: ...
if sys.version_info >= (3, 2):
def getbuffer(self) -> memoryview: ...

class BufferedReader(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
if sys.version_info >= (3, 4):
def peek(self, size: int = ...) -> bytes: ...
else:
def peek(self, n: int = ...) -> bytes: ... # type: ignore

class BufferedWriter(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
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: int = ...) -> int: ...
def writable(self) -> bool: ...
def write(self, s: str) -> int: ...
def writelines(self, lines: Iterable[str]) -> None: ...
def getvalue(self) -> str: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...

def __iter__(self) -> Iterator[str]: ...
def __enter__(self) -> 'StringIO': ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...

class TextIOWrapper(TextIO):
# TODO: This is actually a base class of _io._TextIOBase.
# write_through is undocumented but used by subprocess
def __init__(self, buffer: IO[bytes], encoding: str = ...,
errors: str = ..., newline: str = ...,
line_buffering: bool = ...,
write_through: bool = ...) -> None: ...
# TODO see comments in BinaryIO for missing functionality
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, n: int = ...) -> str: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
class BufferedRandom(BufferedReader, BufferedWriter):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> int: ...
def writable(self) -> bool: ...

class BufferedRWPair(BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase,
buffer_size: int = ...) -> None: ...


class TextIOBase(IOBase):
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) -> 'TextIOBase': ...
def detach(self) -> IOBase: ...
def write(self, s: str) -> int: ...
def writelines(self, lines: Iterable[str]) -> None: ...
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 TextIOWrapper(TextIOBase):
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: ...
else:
def __init__(self, buffer: BufferedIOBase, # type: ignore
encoding: str = ..., errors: Optional[str] = ...,
newline: Optional[str] = ..., line_buffering: bool = ...) \
-> None: ...

class StringIO(TextIOWrapper):
def __init__(self, initial_value: str = ...,
newline: Optional[str] = ...) -> None: ...
def getvalue(self) -> str: ...

def __iter__(self) -> Iterator[str]: ...
def __enter__(self) -> StringIO: ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
class IncrementalNewlineDecoder(codecs.IncrementalDecoder): ...