mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 12:35:49 +08:00
Always use _typeshed.Self, where applicable (#6880)
* Always use `_typeshed.Self`, where applicable * Revert changes to `google-cloud-ndb` (ambiguous) * Remove empty line added by script * Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi` * Manually add a few more that the script missed * Improve `filelock` annotation Source code here: https://github.com/tox-dev/py-filelock/blob/79ec7b2826e33b982fe83b057f359448b9d966ba/src/filelock/_api.py#L207 * Improve `opentracing/scope` annotation Source code here: https://github.com/opentracing/opentracing-python/blob/3e1d357a348269ef54d67f761302fab93dbfc0f7/opentracing/scope.py#L71 * Improve `redis/client` stub Source code here: https://github.com/redis/redis-py/blob/15f315a496c3267c8cbcc6d6d9c6005ea4d4a4d5/redis/client.py#L1217 * Improve `redis/lock` annotation Source code here: https://github.com/redis/redis-py/blob/15f315a496c3267c8cbcc6d6d9c6005ea4d4a4d5/redis/lock.py#L155 * Improve `requests/models` annotation Source code here: https://github.com/psf/requests/blob/d718e753834b84018014a23d663369ac27d1ab9c/requests/models.py#L653
This commit is contained in:
+3
-7
@@ -2,7 +2,7 @@ import sys
|
||||
import types
|
||||
from _typeshed import Self
|
||||
from abc import abstractmethod
|
||||
from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, TypeVar, overload
|
||||
from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
BOM32_BE: Literal[b"\xfe\xff"]
|
||||
@@ -201,8 +201,6 @@ class StreamReader(Codec):
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
|
||||
|
||||
_T = TypeVar("_T", bound=StreamReaderWriter)
|
||||
|
||||
# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing
|
||||
# and delegates attributes to the underlying binary stream with __getattr__.
|
||||
class StreamReaderWriter(TextIO):
|
||||
@@ -211,7 +209,7 @@ class StreamReaderWriter(TextIO):
|
||||
def readline(self, size: int | None = ...) -> str: ...
|
||||
def readlines(self, sizehint: int | None = ...) -> list[str]: ...
|
||||
def __next__(self) -> str: ...
|
||||
def __iter__(self: _T) -> _T: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
# This actually returns None, but that's incompatible with the supertype
|
||||
def write(self, data: str) -> int: ...
|
||||
def writelines(self, list: Iterable[str]) -> None: ...
|
||||
@@ -233,8 +231,6 @@ class StreamReaderWriter(TextIO):
|
||||
def tell(self) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
|
||||
_SRT = TypeVar("_SRT", bound=StreamRecoder)
|
||||
|
||||
class StreamRecoder(BinaryIO):
|
||||
def __init__(
|
||||
self,
|
||||
@@ -249,7 +245,7 @@ class StreamRecoder(BinaryIO):
|
||||
def readline(self, size: int | None = ...) -> bytes: ...
|
||||
def readlines(self, sizehint: int | None = ...) -> list[bytes]: ...
|
||||
def __next__(self) -> bytes: ...
|
||||
def __iter__(self: _SRT) -> _SRT: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def write(self, data: bytes) -> int: ...
|
||||
def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None
|
||||
def reset(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user