mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-08 22:36:18 +08:00
Made parameters of collections.abc members positional only (#15305)
This commit is contained in:
@@ -204,8 +204,26 @@ _collections_abc\.ByteString
|
||||
typing\.ByteString
|
||||
|
||||
_collections_abc.Callable # Typing-related weirdness
|
||||
_collections_abc.Mapping.get # Adding None to the Union messed up mypy
|
||||
_collections_abc.Sequence.index # Supporting None in end is not mandatory
|
||||
|
||||
# While the implementation in _collections_abc.py uses positional-or-keyword args,
|
||||
# this is unsafe as canonical types list/dict/set etc. only support positional args.
|
||||
# See: https://github.com/python/typeshed/issues/14071
|
||||
# See: https://github.com/python/cpython/issues/135312
|
||||
_collections_abc.Mapping.get
|
||||
_collections_abc.MutableSequence.append
|
||||
_collections_abc.MutableSequence.extend
|
||||
_collections_abc.MutableSequence.insert
|
||||
_collections_abc.MutableSequence.pop
|
||||
_collections_abc.MutableSequence.remove
|
||||
_collections_abc.MutableSet.add
|
||||
_collections_abc.MutableSet.discard
|
||||
_collections_abc.MutableSet.remove
|
||||
_collections_abc.Sequence.count
|
||||
_collections_abc.Sequence.index
|
||||
_collections_abc.Set.isdisjoint
|
||||
_collections_abc.Set._from_iterable
|
||||
_collections_abc.ItemsView._from_iterable
|
||||
_collections_abc.KeysView._from_iterable
|
||||
|
||||
_ctypes.CFuncPtr # stubtest erroneously thinks it can't be subclassed
|
||||
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ class ABCMeta(type):
|
||||
mcls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any
|
||||
) -> _typeshed.Self: ...
|
||||
|
||||
def __instancecheck__(cls: ABCMeta, instance: Any) -> bool: ...
|
||||
def __subclasscheck__(cls: ABCMeta, subclass: type) -> bool: ...
|
||||
def __instancecheck__(cls: ABCMeta, instance: Any, /) -> bool: ...
|
||||
def __subclasscheck__(cls: ABCMeta, subclass: type, /) -> bool: ...
|
||||
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = None) -> None: ...
|
||||
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
|
||||
|
||||
|
||||
+57
-57
@@ -658,78 +658,78 @@ class Collection(Iterable[_T_co], Container[Any], Protocol[_T_co]):
|
||||
class Sequence(Reversible[_T_co], Collection[_T_co]):
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __getitem__(self, index: int) -> _T_co: ...
|
||||
def __getitem__(self, index: int, /) -> _T_co: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __getitem__(self, index: slice[int | None]) -> Sequence[_T_co]: ...
|
||||
def __getitem__(self, index: slice[int | None], /) -> Sequence[_T_co]: ...
|
||||
# Mixin methods
|
||||
def index(self, value: Any, start: int = 0, stop: int = ...) -> int: ...
|
||||
def count(self, value: Any) -> int: ...
|
||||
def __contains__(self, value: object) -> bool: ...
|
||||
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
|
||||
def count(self, value: Any, /) -> int: ...
|
||||
def __contains__(self, value: object, /) -> bool: ...
|
||||
def __iter__(self) -> Iterator[_T_co]: ...
|
||||
def __reversed__(self) -> Iterator[_T_co]: ...
|
||||
|
||||
class MutableSequence(Sequence[_T]):
|
||||
@abstractmethod
|
||||
def insert(self, index: int, value: _T) -> None: ...
|
||||
def insert(self, index: int, value: _T, /) -> None: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __getitem__(self, index: int) -> _T: ...
|
||||
def __getitem__(self, index: int, /) -> _T: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __getitem__(self, index: slice[int | None]) -> MutableSequence[_T]: ...
|
||||
def __getitem__(self, index: slice[int | None], /) -> MutableSequence[_T]: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __setitem__(self, index: int, value: _T) -> None: ...
|
||||
def __setitem__(self, index: int, value: _T, /) -> None: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __setitem__(self, index: slice[int | None], value: Iterable[_T]) -> None: ...
|
||||
def __setitem__(self, index: slice[int | None], value: Iterable[_T], /) -> None: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __delitem__(self, index: int) -> None: ...
|
||||
def __delitem__(self, index: int, /) -> None: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def __delitem__(self, index: slice[int | None]) -> None: ...
|
||||
def __delitem__(self, index: slice[int | None], /) -> None: ...
|
||||
# Mixin methods
|
||||
def append(self, value: _T) -> None: ...
|
||||
def append(self, value: _T, /) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def extend(self, values: Iterable[_T]) -> None: ...
|
||||
def extend(self, values: Iterable[_T], /) -> None: ...
|
||||
def reverse(self) -> None: ...
|
||||
def pop(self, index: int = -1) -> _T: ...
|
||||
def remove(self, value: _T) -> None: ...
|
||||
def __iadd__(self, values: Iterable[_T]) -> typing_extensions.Self: ...
|
||||
def pop(self, index: int = -1, /) -> _T: ...
|
||||
def remove(self, value: _T, /) -> None: ...
|
||||
def __iadd__(self, values: Iterable[_T], /) -> typing_extensions.Self: ...
|
||||
|
||||
class AbstractSet(Collection[_T_co]):
|
||||
@abstractmethod
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
def __contains__(self, x: object, /) -> bool: ...
|
||||
def _hash(self) -> int: ...
|
||||
# Mixin methods
|
||||
@classmethod
|
||||
def _from_iterable(cls, it: Iterable[_S]) -> AbstractSet[_S]: ...
|
||||
def __le__(self, other: AbstractSet[Any]) -> bool: ...
|
||||
def __lt__(self, other: AbstractSet[Any]) -> bool: ...
|
||||
def __gt__(self, other: AbstractSet[Any]) -> bool: ...
|
||||
def __ge__(self, other: AbstractSet[Any]) -> bool: ...
|
||||
def __and__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
|
||||
def __or__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
|
||||
def __sub__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
|
||||
def __xor__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def isdisjoint(self, other: Iterable[Any]) -> bool: ...
|
||||
def _from_iterable(cls, it: Iterable[_S], /) -> AbstractSet[_S]: ...
|
||||
def __le__(self, other: AbstractSet[Any], /) -> bool: ...
|
||||
def __lt__(self, other: AbstractSet[Any], /) -> bool: ...
|
||||
def __gt__(self, other: AbstractSet[Any], /) -> bool: ...
|
||||
def __ge__(self, other: AbstractSet[Any], /) -> bool: ...
|
||||
def __and__(self, other: AbstractSet[Any], /) -> AbstractSet[_T_co]: ...
|
||||
def __or__(self, other: AbstractSet[_T], /) -> AbstractSet[_T_co | _T]: ...
|
||||
def __sub__(self, other: AbstractSet[Any], /) -> AbstractSet[_T_co]: ...
|
||||
def __xor__(self, other: AbstractSet[_T], /) -> AbstractSet[_T_co | _T]: ...
|
||||
def __eq__(self, other: object, /) -> bool: ...
|
||||
def isdisjoint(self, other: Iterable[Any], /) -> bool: ...
|
||||
|
||||
class MutableSet(AbstractSet[_T]):
|
||||
@abstractmethod
|
||||
def add(self, value: _T) -> None: ...
|
||||
def add(self, value: _T, /) -> None: ...
|
||||
@abstractmethod
|
||||
def discard(self, value: _T) -> None: ...
|
||||
def discard(self, value: _T, /) -> None: ...
|
||||
# Mixin methods
|
||||
def clear(self) -> None: ...
|
||||
def pop(self) -> _T: ...
|
||||
def remove(self, value: _T) -> None: ...
|
||||
def __ior__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc]
|
||||
def __iand__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
|
||||
def __ixor__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc]
|
||||
def __isub__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
|
||||
def remove(self, value: _T, /) -> None: ...
|
||||
def __ior__(self, it: AbstractSet[_T], /) -> typing_extensions.Self: ... # type: ignore[override,misc]
|
||||
def __iand__(self, it: AbstractSet[Any], /) -> typing_extensions.Self: ...
|
||||
def __ixor__(self, it: AbstractSet[_T], /) -> typing_extensions.Self: ... # type: ignore[override,misc]
|
||||
def __isub__(self, it: AbstractSet[Any], /) -> typing_extensions.Self: ...
|
||||
|
||||
class MappingView(Sized):
|
||||
__slots__ = ("_mapping",)
|
||||
@@ -739,36 +739,36 @@ class MappingView(Sized):
|
||||
class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
|
||||
def __init__(self, mapping: SupportsGetItemViewable[_KT_co, _VT_co]) -> None: ... # undocumented
|
||||
@classmethod
|
||||
def _from_iterable(cls, it: Iterable[_S]) -> set[_S]: ...
|
||||
def __and__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
|
||||
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
|
||||
def __contains__(self, item: tuple[object, object]) -> bool: ... # type: ignore[override]
|
||||
def _from_iterable(cls, it: Iterable[_S], /) -> set[_S]: ...
|
||||
def __and__(self, other: Iterable[Any], /) -> set[tuple[_KT_co, _VT_co]]: ...
|
||||
def __rand__(self, other: Iterable[_T], /) -> set[_T]: ...
|
||||
def __contains__(self, item: tuple[object, object], /) -> bool: ... # type: ignore[override]
|
||||
def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
|
||||
def __or__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __ror__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __sub__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
|
||||
def __rsub__(self, other: Iterable[_T]) -> set[_T]: ...
|
||||
def __xor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __rxor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __or__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __ror__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __sub__(self, other: Iterable[Any], /) -> set[tuple[_KT_co, _VT_co]]: ...
|
||||
def __rsub__(self, other: Iterable[_T], /) -> set[_T]: ...
|
||||
def __xor__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
def __rxor__(self, other: Iterable[_T], /) -> set[tuple[_KT_co, _VT_co] | _T]: ...
|
||||
|
||||
class KeysView(MappingView, AbstractSet[_KT_co]):
|
||||
def __init__(self, mapping: Viewable[_KT_co]) -> None: ... # undocumented
|
||||
@classmethod
|
||||
def _from_iterable(cls, it: Iterable[_S]) -> set[_S]: ...
|
||||
def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ...
|
||||
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
|
||||
def __contains__(self, key: object) -> bool: ...
|
||||
def _from_iterable(cls, it: Iterable[_S], /) -> set[_S]: ...
|
||||
def __and__(self, other: Iterable[Any], /) -> set[_KT_co]: ...
|
||||
def __rand__(self, other: Iterable[_T], /) -> set[_T]: ...
|
||||
def __contains__(self, key: object, /) -> bool: ...
|
||||
def __iter__(self) -> Iterator[_KT_co]: ...
|
||||
def __or__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
|
||||
def __ror__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
|
||||
def __sub__(self, other: Iterable[Any]) -> set[_KT_co]: ...
|
||||
def __rsub__(self, other: Iterable[_T]) -> set[_T]: ...
|
||||
def __xor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
|
||||
def __rxor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
|
||||
def __or__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
|
||||
def __ror__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
|
||||
def __sub__(self, other: Iterable[Any], /) -> set[_KT_co]: ...
|
||||
def __rsub__(self, other: Iterable[_T], /) -> set[_T]: ...
|
||||
def __xor__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
|
||||
def __rxor__(self, other: Iterable[_T], /) -> set[_KT_co | _T]: ...
|
||||
|
||||
class ValuesView(MappingView, Collection[_VT_co]):
|
||||
def __init__(self, mapping: SupportsGetItemViewable[Any, _VT_co]) -> None: ... # undocumented
|
||||
def __contains__(self, value: object) -> bool: ...
|
||||
def __contains__(self, value: object, /) -> bool: ...
|
||||
def __iter__(self) -> Iterator[_VT_co]: ...
|
||||
|
||||
# note for Mapping.get and MutableMapping.pop and MutableMapping.setdefault
|
||||
|
||||
Reference in New Issue
Block a user