Skip to content

Sync typeshed #18403

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 7 commits into from
Jan 1, 2025
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 25250cbe1f7ee0e924ac03b3f19297e1885dd13e Mon Sep 17 00:00:00 2001
From abc5225e3c69d7ae8f3388c87260fe496efaecac Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Sat, 21 Dec 2024 22:36:38 +0100
Subject: [PATCH] Revert Remove redundant inheritances from Iterator in
Expand All @@ -15,7 +15,7 @@ Subject: [PATCH] Revert Remove redundant inheritances from Iterator in
7 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/mypy/typeshed/stdlib/_asyncio.pyi b/mypy/typeshed/stdlib/_asyncio.pyi
index a25902661..18920cd8a 100644
index 89cdff6cc..1397e579d 100644
--- a/mypy/typeshed/stdlib/_asyncio.pyi
+++ b/mypy/typeshed/stdlib/_asyncio.pyi
@@ -1,6 +1,6 @@
Expand All @@ -36,7 +36,7 @@ index a25902661..18920cd8a 100644
@property
def _exception(self) -> BaseException | None: ...
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index 5c6d321f7..56a5969d1 100644
index b75e34fc5..526406acc 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -1130,7 +1130,7 @@ class frozenset(AbstractSet[_T_co]):
Expand Down Expand Up @@ -64,7 +64,7 @@ index 5c6d321f7..56a5969d1 100644
-class map(Generic[_S]):
+class map(Iterator[_S]):
@overload
def __new__(cls, func: Callable[[_T1], _S], iter1: Iterable[_T1], /) -> Self: ...
def __new__(cls, func: Callable[[_T1], _S], iterable: Iterable[_T1], /) -> Self: ...
@overload
@@ -1632,7 +1632,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex

Expand Down Expand Up @@ -131,7 +131,7 @@ index bf6daad0a..1e6aa78e2 100644
# encoding and errors are added
@overload
diff --git a/mypy/typeshed/stdlib/itertools.pyi b/mypy/typeshed/stdlib/itertools.pyi
index 013c3cba1..f69665882 100644
index 55b0814ac..675533d44 100644
--- a/mypy/typeshed/stdlib/itertools.pyi
+++ b/mypy/typeshed/stdlib/itertools.pyi
@@ -29,7 +29,7 @@ _Predicate: TypeAlias = Callable[[_T], object]
Expand All @@ -149,14 +149,14 @@ index 013c3cba1..f69665882 100644

-class cycle(Generic[_T]):
+class cycle(Iterator[_T]):
def __init__(self, iterable: Iterable[_T], /) -> None: ...
def __new__(cls, iterable: Iterable[_T], /) -> Self: ...
def __next__(self) -> _T: ...
def __iter__(self) -> Self: ...

-class repeat(Generic[_T]):
+class repeat(Iterator[_T]):
@overload
def __init__(self, object: _T) -> None: ...
def __new__(cls, object: _T) -> Self: ...
@overload
@@ -53,7 +53,7 @@ class repeat(Generic[_T]):
def __iter__(self) -> Self: ...
Expand All @@ -165,15 +165,15 @@ index 013c3cba1..f69665882 100644
-class accumulate(Generic[_T]):
+class accumulate(Iterator[_T]):
@overload
def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> Self: ...
@overload
@@ -61,7 +61,7 @@ class accumulate(Generic[_T]):
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

-class chain(Generic[_T]):
+class chain(Iterator[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...
def __new__(cls, *iterables: Iterable[_T]) -> Self: ...
def __next__(self) -> _T: ...
def __iter__(self) -> Self: ...
@@ -71,22 +71,22 @@ class chain(Generic[_T]):
Expand All @@ -182,19 +182,19 @@ index 013c3cba1..f69665882 100644

-class compress(Generic[_T]):
+class compress(Iterator[_T]):
def __init__(self, data: Iterable[_T], selectors: Iterable[Any]) -> None: ...
def __new__(cls, data: Iterable[_T], selectors: Iterable[Any]) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

-class dropwhile(Generic[_T]):
+class dropwhile(Iterator[_T]):
def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

-class filterfalse(Generic[_T]):
+class filterfalse(Iterator[_T]):
def __init__(self, predicate: _Predicate[_T] | None, iterable: Iterable[_T], /) -> None: ...
def __new__(cls, function: _Predicate[_T] | None, iterable: Iterable[_T], /) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

Expand All @@ -210,7 +210,7 @@ index 013c3cba1..f69665882 100644
-class islice(Generic[_T]):
+class islice(Iterator[_T]):
@overload
def __init__(self, iterable: Iterable[_T], stop: int | None, /) -> None: ...
def __new__(cls, iterable: Iterable[_T], stop: int | None, /) -> Self: ...
@overload
@@ -102,19 +102,19 @@ class islice(Generic[_T]):
def __iter__(self) -> Self: ...
Expand All @@ -224,7 +224,7 @@ index 013c3cba1..f69665882 100644

-class takewhile(Generic[_T]):
+class takewhile(Iterator[_T]):
def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

Expand Down Expand Up @@ -288,17 +288,17 @@ index 013c3cba1..f69665882 100644
def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
else:
diff --git a/mypy/typeshed/stdlib/multiprocessing/pool.pyi b/mypy/typeshed/stdlib/multiprocessing/pool.pyi
index 61d6d0781..950ed1d8c 100644
index 2937d45e3..93197e5d4 100644
--- a/mypy/typeshed/stdlib/multiprocessing/pool.pyi
+++ b/mypy/typeshed/stdlib/multiprocessing/pool.pyi
@@ -1,5 +1,5 @@
import sys
-from collections.abc import Callable, Iterable, Mapping
+from collections.abc import Callable, Iterable, Iterator, Mapping
from multiprocessing.context import DefaultContext, Process
from types import TracebackType
from typing import Any, Final, Generic, TypeVar
from typing_extensions import Self
@@ -36,7 +36,7 @@ class MapResult(ApplyResult[list[_T]]):
@@ -37,7 +37,7 @@ class MapResult(ApplyResult[list[_T]]):
error_callback: Callable[[BaseException], object] | None,
) -> None: ...

Expand All @@ -308,7 +308,7 @@ index 61d6d0781..950ed1d8c 100644
def __iter__(self) -> Self: ...
def next(self, timeout: float | None = None) -> _T: ...
diff --git a/mypy/typeshed/stdlib/sqlite3/__init__.pyi b/mypy/typeshed/stdlib/sqlite3/__init__.pyi
index bc0ff6469..730404bde 100644
index b83516b4d..724bc3166 100644
--- a/mypy/typeshed/stdlib/sqlite3/__init__.pyi
+++ b/mypy/typeshed/stdlib/sqlite3/__init__.pyi
@@ -397,7 +397,7 @@ class Connection:
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_asyncio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
loop: AbstractEventLoop | None = None,
name: str | None = ...,
context: Context | None = None,
eager_start: bool = False,
Expand All @@ -75,13 +75,13 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
loop: AbstractEventLoop | None = None,
name: str | None = ...,
context: Context | None = None,
) -> None: ...
else:
def __init__(
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop | None = None, name: str | None = ...
) -> None: ...

if sys.version_info >= (3, 12):
Expand Down
24 changes: 12 additions & 12 deletions mypy/typeshed/stdlib/_blake2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class blake2b:
digest_size: int
name: str
if sys.version_info >= (3, 9):
def __init__(
self,
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
Expand All @@ -39,10 +39,10 @@ class blake2b:
inner_size: int = 0,
last_node: bool = False,
usedforsecurity: bool = True,
) -> None: ...
) -> Self: ...
else:
def __init__(
self,
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
Expand All @@ -57,7 +57,7 @@ class blake2b:
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
) -> None: ...
) -> Self: ...

def copy(self) -> Self: ...
def digest(self) -> bytes: ...
Expand All @@ -74,8 +74,8 @@ class blake2s:
digest_size: int
name: str
if sys.version_info >= (3, 9):
def __init__(
self,
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
Expand All @@ -91,10 +91,10 @@ class blake2s:
inner_size: int = 0,
last_node: bool = False,
usedforsecurity: bool = True,
) -> None: ...
) -> Self: ...
else:
def __init__(
self,
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
Expand All @@ -109,7 +109,7 @@ class blake2s:
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
) -> None: ...
) -> Self: ...

def copy(self) -> Self: ...
def digest(self) -> bytes: ...
Expand Down
8 changes: 7 additions & 1 deletion mypy/typeshed/stdlib/_bz2.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import sys
from _typeshed import ReadableBuffer
from typing import final
from typing_extensions import Self

@final
class BZ2Compressor:
def __init__(self, compresslevel: int = 9) -> None: ...
if sys.version_info >= (3, 12):
def __new__(cls, compresslevel: int = 9, /) -> Self: ...
else:
def __init__(self, compresslevel: int = 9, /) -> None: ...

def compress(self, data: ReadableBuffer, /) -> bytes: ...
def flush(self) -> bytes: ...

Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from typing import ( # noqa: Y022,Y038
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
Callable as Callable,
ClassVar,
Collection as Collection,
Container as Container,
Coroutine as Coroutine,
Expand Down Expand Up @@ -74,6 +75,7 @@ _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
def __eq__(self, value: object, /) -> bool: ...
def __reversed__(self) -> Iterator[_KT_co]: ...
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 13):
def isdisjoint(self, other: Iterable[_KT_co], /) -> bool: ...
if sys.version_info >= (3, 10):
Expand All @@ -91,6 +93,7 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
def __eq__(self, value: object, /) -> bool: ...
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 13):
def isdisjoint(self, other: Iterable[tuple[_KT_co, _VT_co]], /) -> bool: ...
if sys.version_info >= (3, 10):
Expand Down
8 changes: 5 additions & 3 deletions mypy/typeshed/stdlib/_contextvars.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable, Iterator, Mapping
from typing import Any, ClassVar, Generic, TypeVar, final, overload
from typing_extensions import ParamSpec
from typing_extensions import ParamSpec, Self

if sys.version_info >= (3, 9):
from types import GenericAlias
Expand All @@ -13,9 +13,9 @@ _P = ParamSpec("_P")
@final
class ContextVar(Generic[_T]):
@overload
def __init__(self, name: str) -> None: ...
def __new__(cls, name: str) -> Self: ...
@overload
def __init__(self, name: str, *, default: _T) -> None: ...
def __new__(cls, name: str, *, default: _T) -> Self: ...
def __hash__(self) -> int: ...
@property
def name(self) -> str: ...
Expand All @@ -37,6 +37,7 @@ class Token(Generic[_T]):
@property
def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express
MISSING: ClassVar[object]
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

Expand All @@ -55,6 +56,7 @@ class Context(Mapping[ContextVar[Any], Any]):
def get(self, key: ContextVar[_T], default: _D, /) -> _T | _D: ...
def run(self, callable: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
def copy(self) -> Context: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __getitem__(self, key: ContextVar[_T], /) -> _T: ...
def __iter__(self) -> Iterator[ContextVar[Any]]: ...
def __len__(self) -> int: ...
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Dialect:
lineterminator: str
quoting: _QuotingType
strict: bool
def __init__(
self,
def __new__(
cls,
dialect: _DialectLike | None = ...,
delimiter: str = ",",
doublequote: bool = True,
Expand All @@ -43,7 +43,7 @@ class Dialect:
quoting: _QuotingType = 0,
skipinitialspace: bool = False,
strict: bool = False,
) -> None: ...
) -> Self: ...

if sys.version_info >= (3, 10):
# This class calls itself _csv.reader.
Expand Down Expand Up @@ -115,7 +115,7 @@ def reader(
) -> _reader: ...
def register_dialect(
name: str,
dialect: type[Dialect] = ...,
dialect: type[Dialect | csv.Dialect] = ...,
*,
delimiter: str = ",",
quotechar: str | None = '"',
Expand Down
14 changes: 7 additions & 7 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,18 @@ class CFuncPtr(_PointerLike, _CData, metaclass=_PyCFuncPtrType):
# Abstract attribute that must be defined on subclasses
_flags_: ClassVar[int]
@overload
def __init__(self) -> None: ...
def __new__(cls) -> Self: ...
@overload
def __init__(self, address: int, /) -> None: ...
def __new__(cls, address: int, /) -> Self: ...
@overload
def __init__(self, callable: Callable[..., Any], /) -> None: ...
def __new__(cls, callable: Callable[..., Any], /) -> Self: ...
@overload
def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] | None = ..., /) -> None: ...
def __new__(cls, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] | None = ..., /) -> Self: ...
if sys.platform == "win32":
@overload
def __init__(
self, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] | None = ..., iid: _CData | _CDataType | None = ..., /
) -> None: ...
def __new__(
cls, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] | None = ..., iid: _CData | _CDataType | None = ..., /
) -> Self: ...

def __call__(self, *args: Any, **kwargs: Any) -> Any: ...

Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadOnlyBuffer, SupportsRead
from _typeshed import ReadOnlyBuffer, SupportsRead, SupportsWrite
from curses import _ncurses_version
from typing import IO, Any, final, overload
from typing import Any, final, overload
from typing_extensions import TypeAlias

# NOTE: This module is ordinarily only available on Unix, but the windows-curses
Expand Down Expand Up @@ -517,7 +517,7 @@ class window: # undocumented
def overwrite(
self, destwin: window, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
def putwin(self, file: IO[Any], /) -> None: ...
def putwin(self, file: SupportsWrite[bytes], /) -> None: ...
def redrawln(self, beg: int, num: int, /) -> None: ...
def redrawwin(self) -> None: ...
@overload
Expand Down
Loading
Loading