Skip to content

Add StringIO.name and BytesIO.name #1802

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 2 commits into from
Jan 26, 2018
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
8 changes: 8 additions & 0 deletions stdlib/2/_io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class BytesIO(_BufferedIOBase):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
def __setstate__(self, tuple) -> None: ...
def __getstate__(self) -> tuple: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> bytes: ...
def write(self, s: bytes) -> int: ...
def writelines(self, lines: Iterable[bytes]) -> None: ...
Expand Down Expand Up @@ -145,6 +149,10 @@ class StringIO(_TextIOBase):
newline: Optional[unicode] = ...) -> None: ...
def __setstate__(self, state: tuple) -> None: ...
def __getstate__(self) -> tuple: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> unicode: ...

class TextIOWrapper(_TextIOBase):
Expand Down
9 changes: 8 additions & 1 deletion stdlib/3/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class FileIO(RawIOBase):
# TODO should extend from BufferedIOBase
class BytesIO(BinaryIO):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> bytes: ...
if sys.version_info >= (3, 2):
def getbuffer(self) -> memoryview: ...
Expand Down Expand Up @@ -248,7 +252,10 @@ class TextIOWrapper(TextIO):
class StringIO(TextIOWrapper):
def __init__(self, initial_value: str = ...,
newline: Optional[str] = ...) -> None: ...
name = ... # type: str
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> str: ...
def __enter__(self) -> 'StringIO': ...

Expand Down