mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Add StringIO.name and BytesIO.name (#1802)
Also, change the type of StringIO.name (Python 3) from str to Any. Neither StringIO nor BytesIO actually define a name field, but the super-class IO[T] of both in typeshed does define a read-only property. This means that sub-classes of StringIO and BytesIO adding this field will not typecheck correctly. Closes: #1790
This commit is contained in:
committed by
Jelle Zijlstra
parent
a08d57833f
commit
6d7173b70b
@@ -82,6 +82,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: ...
|
||||
@@ -148,6 +152,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):
|
||||
|
||||
@@ -98,6 +98,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: ...
|
||||
@@ -251,7 +255,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': ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user