Skip to content

Commit 0bffc56

Browse files
github-actions[bot]cdce8phauntsaninjaAlexWaygood
authored
Sync typeshed (#20932)
Sync typeshed Source commit: python/typeshed@843c1fd Note that you will need to close and re-open the PR in order to trigger CI. --------- Co-authored-by: mypybot <> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: AlexWaygood <alex.waygood@gmail.com> Co-authored-by: Shantanu Jain <hauntsaninja@gmail.com>
1 parent 1d8ddd5 commit 0bffc56

8 files changed

Lines changed: 101 additions & 69 deletions

File tree

mypy/typeshed/stdlib/abc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class ABCMeta(type):
2222
mcls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any
2323
) -> _typeshed.Self: ...
2424

25-
def __instancecheck__(cls: ABCMeta, instance: Any) -> bool: ...
26-
def __subclasscheck__(cls: ABCMeta, subclass: type) -> bool: ...
25+
def __instancecheck__(cls: ABCMeta, instance: Any, /) -> bool: ...
26+
def __subclasscheck__(cls: ABCMeta, subclass: type, /) -> bool: ...
2727
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = None) -> None: ...
2828
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
2929

mypy/typeshed/stdlib/asyncio/tasks.pyi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,9 @@ else:
369369
async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ...
370370

371371
if sys.version_info >= (3, 11):
372-
@overload
373372
async def wait(
374373
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
375374
) -> tuple[set[_FT], set[_FT]]: ...
376-
@overload
377-
async def wait(
378-
fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
379-
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
380375

381376
elif sys.version_info >= (3, 10):
382377
@overload

mypy/typeshed/stdlib/multiprocessing/managers.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ from .util import Finalize as _Finalize
2626
__all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token", "SharedMemoryManager"]
2727

2828
_T = TypeVar("_T")
29+
_T1 = TypeVar("_T1")
30+
_T2 = TypeVar("_T2")
2931
_KT = TypeVar("_KT")
3032
_VT = TypeVar("_VT")
3133
_S = TypeVar("_S")
@@ -94,6 +96,25 @@ if sys.version_info >= (3, 13):
9496
def keys(self) -> list[_KT]: ... # type: ignore[override]
9597
def items(self) -> list[tuple[_KT, _VT]]: ... # type: ignore[override]
9698
def values(self) -> list[_VT]: ... # type: ignore[override]
99+
if sys.version_info >= (3, 14):
100+
# Next methods are copied from builtins.dict
101+
@overload
102+
def fromkeys(self, iterable: Iterable[_T], value: None = None, /) -> dict[_T, Any | None]: ...
103+
@overload
104+
def fromkeys(self, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ...
105+
def __reversed__(self) -> Iterator[_KT]: ...
106+
@overload
107+
def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
108+
@overload
109+
def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
110+
@overload
111+
def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
112+
@overload
113+
def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
114+
@overload # type: ignore[misc]
115+
def __ior__(self, value: SupportsKeysAndGetItem[_KT, _VT], /) -> Self: ...
116+
@overload
117+
def __ior__(self, value: Iterable[tuple[_KT, _VT]], /) -> Self: ...
97118

98119
class DictProxy(_BaseDictProxy[_KT, _VT]):
99120
def __class_getitem__(cls, args: Any, /) -> GenericAlias: ...
@@ -193,6 +214,8 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
193214
def insert(self, index: SupportsIndex, object: _T, /) -> None: ...
194215
def remove(self, value: _T, /) -> None: ...
195216
if sys.version_info >= (3, 14):
217+
# Next methods are copied from builtins.list
218+
def clear(self) -> None: ...
196219
def copy(self) -> list[_T]: ...
197220
# Use BaseListProxy[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison]
198221
# to work around invariance

mypy/typeshed/stdlib/multiprocessing/queues.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import sys
22
from types import GenericAlias
3-
from typing import Any, Generic, TypeVar
3+
from typing import Any, Generic, NewType, TypeVar
44

55
__all__ = ["Queue", "SimpleQueue", "JoinableQueue"]
66

77
_T = TypeVar("_T")
88

9+
_QueueState = NewType("_QueueState", object)
10+
_JoinableQueueState = NewType("_JoinableQueueState", object)
11+
_SimpleQueueState = NewType("_SimpleQueueState", object)
12+
913
class Queue(Generic[_T]):
1014
# FIXME: `ctx` is a circular dependency and it's not actually optional.
1115
# It's marked as such to be able to use the generic Queue in __init__.pyi.
1216
def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ...
17+
def __getstate__(self) -> _QueueState: ...
18+
def __setstate__(self, state: _QueueState) -> None: ...
1319
def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ...
1420
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
1521
def qsize(self) -> int: ...
@@ -24,13 +30,17 @@ class Queue(Generic[_T]):
2430
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
2531

2632
class JoinableQueue(Queue[_T]):
33+
def __getstate__(self) -> _JoinableQueueState: ... # type: ignore[override]
34+
def __setstate__(self, state: _JoinableQueueState) -> None: ... # type: ignore[override]
2735
def task_done(self) -> None: ...
2836
def join(self) -> None: ...
2937

3038
class SimpleQueue(Generic[_T]):
3139
def __init__(self, *, ctx: Any = ...) -> None: ...
3240
def close(self) -> None: ...
3341
def empty(self) -> bool: ...
42+
def __getstate__(self) -> _SimpleQueueState: ...
43+
def __setstate__(self, state: _SimpleQueueState) -> None: ...
3444
def get(self) -> _T: ...
3545
def put(self, obj: _T) -> None: ...
3646
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

mypy/typeshed/stdlib/opcode.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if sys.version_info >= (3, 13):
4141
opname: Final[list[str]]
4242

4343
opmap: Final[dict[str, int]]
44-
HAVE_ARGUMENT: Final = 43
45-
EXTENDED_ARG: Final = 69
44+
HAVE_ARGUMENT: Final[int]
45+
EXTENDED_ARG: Final[int]
4646

4747
def stack_effect(opcode: int, oparg: int | None = None, /, *, jump: bool | None = None) -> int: ...

mypy/typeshed/stdlib/pickle.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from _pickle import (
23
PickleError as PickleError,
34
Pickler as Pickler,
@@ -103,7 +104,10 @@ __all__ = [
103104
]
104105

105106
HIGHEST_PROTOCOL: Final = 5
106-
DEFAULT_PROTOCOL: Final = 5
107+
if sys.version_info >= (3, 14):
108+
DEFAULT_PROTOCOL: Final = 5
109+
else:
110+
DEFAULT_PROTOCOL: Final = 4
107111

108112
bytes_types: tuple[type[Any], ...] # undocumented
109113

mypy/typeshed/stdlib/types.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ if sys.version_info >= (3, 10):
733733
def __hash__(self) -> int: ...
734734
# you can only subscript a `UnionType` instance if at least one of the elements
735735
# in the union is a generic alias instance that has a non-empty `__parameters__`
736-
def __getitem__(self, parameters: Any) -> object: ...
736+
def __getitem__(self, parameters: Any, /) -> object: ...
737737

738738
if sys.version_info >= (3, 13):
739739
@final

mypy/typeshed/stdlib/typing.pyi

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -655,78 +655,78 @@ class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
655655
class Sequence(Reversible[_T_co], Collection[_T_co]):
656656
@overload
657657
@abstractmethod
658-
def __getitem__(self, index: int) -> _T_co: ...
658+
def __getitem__(self, index: int, /) -> _T_co: ...
659659
@overload
660660
@abstractmethod
661-
def __getitem__(self, index: slice[int | None]) -> Sequence[_T_co]: ...
661+
def __getitem__(self, index: slice[int | None], /) -> Sequence[_T_co]: ...
662662
# Mixin methods
663-
def index(self, value: Any, start: int = 0, stop: int = ...) -> int: ...
664-
def count(self, value: Any) -> int: ...
665-
def __contains__(self, value: object) -> bool: ...
663+
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
664+
def count(self, value: Any, /) -> int: ...
665+
def __contains__(self, value: object, /) -> bool: ...
666666
def __iter__(self) -> Iterator[_T_co]: ...
667667
def __reversed__(self) -> Iterator[_T_co]: ...
668668

669669
class MutableSequence(Sequence[_T]):
670670
@abstractmethod
671-
def insert(self, index: int, value: _T) -> None: ...
671+
def insert(self, index: int, value: _T, /) -> None: ...
672672
@overload
673673
@abstractmethod
674-
def __getitem__(self, index: int) -> _T: ...
674+
def __getitem__(self, index: int, /) -> _T: ...
675675
@overload
676676
@abstractmethod
677-
def __getitem__(self, index: slice[int | None]) -> MutableSequence[_T]: ...
677+
def __getitem__(self, index: slice[int | None], /) -> MutableSequence[_T]: ...
678678
@overload
679679
@abstractmethod
680-
def __setitem__(self, index: int, value: _T) -> None: ...
680+
def __setitem__(self, index: int, value: _T, /) -> None: ...
681681
@overload
682682
@abstractmethod
683-
def __setitem__(self, index: slice[int | None], value: Iterable[_T]) -> None: ...
683+
def __setitem__(self, index: slice[int | None], value: Iterable[_T], /) -> None: ...
684684
@overload
685685
@abstractmethod
686-
def __delitem__(self, index: int) -> None: ...
686+
def __delitem__(self, index: int, /) -> None: ...
687687
@overload
688688
@abstractmethod
689-
def __delitem__(self, index: slice[int | None]) -> None: ...
689+
def __delitem__(self, index: slice[int | None], /) -> None: ...
690690
# Mixin methods
691-
def append(self, value: _T) -> None: ...
691+
def append(self, value: _T, /) -> None: ...
692692
def clear(self) -> None: ...
693-
def extend(self, values: Iterable[_T]) -> None: ...
693+
def extend(self, values: Iterable[_T], /) -> None: ...
694694
def reverse(self) -> None: ...
695-
def pop(self, index: int = -1) -> _T: ...
696-
def remove(self, value: _T) -> None: ...
697-
def __iadd__(self, values: Iterable[_T]) -> typing_extensions.Self: ...
695+
def pop(self, index: int = -1, /) -> _T: ...
696+
def remove(self, value: _T, /) -> None: ...
697+
def __iadd__(self, values: Iterable[_T], /) -> typing_extensions.Self: ...
698698

699699
class AbstractSet(Collection[_T_co]):
700700
@abstractmethod
701-
def __contains__(self, x: object) -> bool: ...
701+
def __contains__(self, x: object, /) -> bool: ...
702702
def _hash(self) -> int: ...
703703
# Mixin methods
704704
@classmethod
705-
def _from_iterable(cls, it: Iterable[_S]) -> AbstractSet[_S]: ...
706-
def __le__(self, other: AbstractSet[Any]) -> bool: ...
707-
def __lt__(self, other: AbstractSet[Any]) -> bool: ...
708-
def __gt__(self, other: AbstractSet[Any]) -> bool: ...
709-
def __ge__(self, other: AbstractSet[Any]) -> bool: ...
710-
def __and__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
711-
def __or__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
712-
def __sub__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
713-
def __xor__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
714-
def __eq__(self, other: object) -> bool: ...
715-
def isdisjoint(self, other: Iterable[Any]) -> bool: ...
705+
def _from_iterable(cls, it: Iterable[_S], /) -> AbstractSet[_S]: ...
706+
def __le__(self, other: AbstractSet[Any], /) -> bool: ...
707+
def __lt__(self, other: AbstractSet[Any], /) -> bool: ...
708+
def __gt__(self, other: AbstractSet[Any], /) -> bool: ...
709+
def __ge__(self, other: AbstractSet[Any], /) -> bool: ...
710+
def __and__(self, other: AbstractSet[Any], /) -> AbstractSet[_T_co]: ...
711+
def __or__(self, other: AbstractSet[_T], /) -> AbstractSet[_T_co | _T]: ...
712+
def __sub__(self, other: AbstractSet[Any], /) -> AbstractSet[_T_co]: ...
713+
def __xor__(self, other: AbstractSet[_T], /) -> AbstractSet[_T_co | _T]: ...
714+
def __eq__(self, other: object, /) -> bool: ...
715+
def isdisjoint(self, other: Iterable[Any], /) -> bool: ...
716716

717717
class MutableSet(AbstractSet[_T]):
718718
@abstractmethod
719-
def add(self, value: _T) -> None: ...
719+
def add(self, value: _T, /) -> None: ...
720720
@abstractmethod
721-
def discard(self, value: _T) -> None: ...
721+
def discard(self, value: _T, /) -> None: ...
722722
# Mixin methods
723723
def clear(self) -> None: ...
724724
def pop(self) -> _T: ...
725-
def remove(self, value: _T) -> None: ...
726-
def __ior__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc]
727-
def __iand__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
728-
def __ixor__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc]
729-
def __isub__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
725+
def remove(self, value: _T, /) -> None: ...
726+
def __ior__(self, it: AbstractSet[_T], /) -> typing_extensions.Self: ... # type: ignore[override,misc]
727+
def __iand__(self, it: AbstractSet[Any], /) -> typing_extensions.Self: ...
728+
def __ixor__(self, it: AbstractSet[_T], /) -> typing_extensions.Self: ... # type: ignore[override,misc]
729+
def __isub__(self, it: AbstractSet[Any], /) -> typing_extensions.Self: ...
730730

731731
class MappingView(Sized):
732732
__slots__ = ("_mapping",)
@@ -736,36 +736,36 @@ class MappingView(Sized):
736736
class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
737737
def __init__(self, mapping: SupportsGetItemViewable[_KT_co, _VT_co]) -> None: ... # undocumented
738738
@classmethod
739-
def _from_iterable(cls, it: Iterable[_S]) -> set[_S]: ...
740-
def __and__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
741-
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
742-
def __contains__(self, item: tuple[object, object]) -> bool: ... # type: ignore[override]
739+
def _from_iterable(cls, it: Iterable[_S], /) -> set[_S]: ...
740+
def __and__(self, other: Iterable[Any], /) -> set[tuple[_KT_co, _VT_co]]: ...
741+
def __rand__(self, other: Iterable[_T], /) -> set[_T]: ...
742+
def __contains__(self, item: tuple[object, object], /) -> bool: ... # type: ignore[override]
743743
def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
744-
def __or__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
745-
def __ror__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
746-
def __sub__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
747-
def __rsub__(self, other: Iterable[_T]) -> set[_T]: ...
748-
def __xor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
749-
def __rxor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
744+
def __or__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
745+
def __ror__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
746+
def __sub__(self, other: Iterable[Any], /) -> set[tuple[_KT_co, _VT_co]]: ...
747+
def __rsub__(self, other: Iterable[_T], /) -> set[_T]: ...
748+
def __xor__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
749+
def __rxor__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
750750

751751
class KeysView(MappingView, AbstractSet[_KT_co]):
752752
def __init__(self, mapping: Viewable[_KT_co]) -> None: ... # undocumented
753753
@classmethod
754-
def _from_iterable(cls, it: Iterable[_S]) -> set[_S]: ...
755-
def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ...
756-
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
757-
def __contains__(self, key: object) -> bool: ...
754+
def _from_iterable(cls, it: Iterable[_S], /) -> set[_S]: ...
755+
def __and__(self, other: Iterable[Any], /) -> set[_KT_co]: ...
756+
def __rand__(self, other: Iterable[_T], /) -> set[_T]: ...
757+
def __contains__(self, key: object, /) -> bool: ...
758758
def __iter__(self) -> Iterator[_KT_co]: ...
759-
def __or__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
760-
def __ror__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
761-
def __sub__(self, other: Iterable[Any]) -> set[_KT_co]: ...
762-
def __rsub__(self, other: Iterable[_T]) -> set[_T]: ...
763-
def __xor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
764-
def __rxor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
759+
def __or__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
760+
def __ror__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
761+
def __sub__(self, other: Iterable[Any], /) -> set[_KT_co]: ...
762+
def __rsub__(self, other: Iterable[_T], /) -> set[_T]: ...
763+
def __xor__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
764+
def __rxor__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
765765

766766
class ValuesView(MappingView, Collection[_VT_co]):
767767
def __init__(self, mapping: SupportsGetItemViewable[Any, _VT_co]) -> None: ... # undocumented
768-
def __contains__(self, value: object) -> bool: ...
768+
def __contains__(self, value: object, /) -> bool: ...
769769
def __iter__(self) -> Iterator[_VT_co]: ...
770770

771771
# note for Mapping.get and MutableMapping.pop and MutableMapping.setdefault

0 commit comments

Comments
 (0)