Skip to content
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
6 changes: 3 additions & 3 deletions stdlib/asyncio/streams.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from _typeshed import StrPath
from _typeshed import Self, StrPath
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional

from . import events, protocols, transports
Expand Down Expand Up @@ -117,7 +117,7 @@ class StreamWriter:
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
async def drain(self) -> None: ...

class StreamReader:
class StreamReader(AsyncIterator[bytes]):
def __init__(self, limit: int = ..., loop: events.AbstractEventLoop | None = ...) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
Expand All @@ -129,5 +129,5 @@ class StreamReader:
async def readuntil(self, separator: bytes = ...) -> bytes: ...
async def read(self, n: int = ...) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...
def __aiter__(self) -> AsyncIterator[bytes]: ...
def __aiter__(self: Self) -> Self: ...
async def __anext__(self) -> bytes: ...
9 changes: 5 additions & 4 deletions stdlib/codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
def incrementaldecoder(self) -> _IncrementalDecoder: ...
name: str
def __new__(
cls,
cls: type[Self],
encode: _Encoder,
decode: _Decoder,
streamreader: _StreamReader | None = ...,
Expand All @@ -96,7 +96,7 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
name: str | None = ...,
*,
_is_text_encoding: bool | None = ...,
) -> CodecInfo: ...
) -> Self: ...

def getencoder(encoding: str) -> _Encoder: ...
def getdecoder(encoding: str) -> _Decoder: ...
Expand Down Expand Up @@ -189,7 +189,7 @@ class StreamWriter(Codec):
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...

class StreamReader(Codec):
class StreamReader(Codec, Iterator[str]):
errors: str
def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ...
Expand All @@ -198,7 +198,8 @@ class StreamReader(Codec):
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> str: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...

# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing
Expand Down
3 changes: 2 additions & 1 deletion stdlib/csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ from _csv import (
unregister_dialect as unregister_dialect,
writer as writer,
)
from _typeshed import Self
from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
from typing import Any, Generic, TypeVar, overload

Expand Down Expand Up @@ -75,7 +76,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]):
*args: Any,
**kwds: Any,
) -> None: ...
def __iter__(self) -> DictReader[_T]: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> _DictReadMapping[_T, str]: ...

class DictWriter(Generic[_T]):
Expand Down
4 changes: 2 additions & 2 deletions stdlib/fileinput.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def fileno() -> int: ...
def isfirstline() -> bool: ...
def isstdin() -> bool: ...

class FileInput(Iterable[AnyStr], Generic[AnyStr]):
class FileInput(Iterator[AnyStr], Generic[AnyStr]):
if sys.version_info >= (3, 10):
def __init__(
self,
Expand Down Expand Up @@ -83,7 +83,7 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]):
def close(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> AnyStr: ...
if sys.version_info < (3, 11):
def __getitem__(self, i: int) -> AnyStr: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/pdb.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import signal
import sys
from _typeshed import Self
from bdb import Bdb
from cmd import Cmd
from inspect import _SourceObjectType
Expand Down Expand Up @@ -173,4 +174,4 @@ def getsourcelines(obj: _SourceObjectType) -> tuple[list[str], int]: ...
def lasti2lineno(code: CodeType, lasti: int) -> int: ...

class _rstr(str):
def __repr__(self) -> _rstr: ...
def __repr__(self: Self) -> Self: ...
3 changes: 2 additions & 1 deletion stdlib/sre_constants.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _typeshed import Self
from typing import Any

MAXGROUPS: int
Expand All @@ -15,7 +16,7 @@ class error(Exception):

class _NamedIntConstant(int):
name: Any
def __new__(cls, value: int, name: str) -> _NamedIntConstant: ...
def __new__(cls: type[Self], value: int, name: str) -> Self: ...

MAXREPEAT: _NamedIntConstant
OPCODES: list[_NamedIntConstant]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/ssl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class SSLContext:
if sys.version_info >= (3, 8):
keylog_filename: str
post_handshake_auth: bool
def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> SSLContext: ...
def __new__(cls: type[Self], protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...
def __init__(self, protocol: int = ...) -> None: ...
def cert_store_stats(self) -> dict[str, int]: ...
def load_cert_chain(
Expand Down
4 changes: 2 additions & 2 deletions stdlib/weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _P = ParamSpec("_P")
ProxyTypes: tuple[type[Any], ...]

class WeakMethod(ref[_CallableT], Generic[_CallableT]):
def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ...
def __new__(cls: type[Self], meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> Self: ...
def __call__(self) -> _CallableT | None: ...

class WeakValueDictionary(MutableMapping[_KT, _VT]):
Expand Down Expand Up @@ -67,7 +67,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
class KeyedRef(ref[_T], Generic[_KT, _T]):
key: _KT
# This __new__ method uses a non-standard name for the "cls" parameter
def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> KeyedRef[_KT, _T]: ... # type: ignore
def __new__(type: type[Self], ob: _T, callback: Callable[[_T], Any], key: _KT) -> Self: ... # type: ignore
def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ...

class WeakKeyDictionary(MutableMapping[_KT, _VT]):
Expand Down