mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-30 06:35:22 +08:00
Use _typeshed.Self with __enter__ (#5712)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import types
|
||||
from _typeshed import Self
|
||||
from abc import abstractmethod
|
||||
from typing import (
|
||||
IO,
|
||||
@@ -188,8 +189,6 @@ class BufferedIncrementalDecoder(IncrementalDecoder):
|
||||
def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[str, int]: ...
|
||||
def decode(self, input: bytes, final: bool = ...) -> str: ...
|
||||
|
||||
_SW = TypeVar("_SW", bound=StreamWriter)
|
||||
|
||||
# TODO: it is not possible to specify the requirement that all other
|
||||
# attributes and methods are passed-through from the stream.
|
||||
class StreamWriter(Codec):
|
||||
@@ -198,14 +197,12 @@ class StreamWriter(Codec):
|
||||
def write(self, object: str) -> None: ...
|
||||
def writelines(self, list: Iterable[str]) -> None: ...
|
||||
def reset(self) -> None: ...
|
||||
def __enter__(self: _SW) -> _SW: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
|
||||
|
||||
_SR = TypeVar("_SR", bound=StreamReader)
|
||||
|
||||
class StreamReader(Codec):
|
||||
errors: str
|
||||
def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ...
|
||||
@@ -213,7 +210,7 @@ class StreamReader(Codec):
|
||||
def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> str: ...
|
||||
def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[str]: ...
|
||||
def reset(self) -> None: ...
|
||||
def __enter__(self: _SR) -> _SR: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
@@ -237,7 +234,7 @@ class StreamReaderWriter(TextIO):
|
||||
def reset(self) -> None: ...
|
||||
# Same as write()
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
@@ -275,7 +272,7 @@ class StreamRecoder(BinaryIO):
|
||||
def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None
|
||||
def reset(self) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __enter__(self: _SRT) -> _SRT: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user