Skip to content

collections.abc: use positional-only for dunder methods #14380

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
142 changes: 71 additions & 71 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ class TypeVar:
contravariant: bool = False,
) -> None: ...
if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ... # AnnotationForm
def __ror__(self, left: Any) -> _SpecialForm: ... # AnnotationForm
def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm
def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Any) -> Any: ...
def __typing_subst__(self, arg: Any, /) -> Any: ...
if sys.version_info >= (3, 13):
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
def has_default(self) -> bool: ...
if sys.version_info >= (3, 14):
@property
Expand All @@ -229,10 +229,10 @@ _promote = object()
# N.B. Keep this definition in sync with typing_extensions._SpecialForm
@final
class _SpecialForm(_Final):
def __getitem__(self, parameters: Any) -> object: ...
def __getitem__(self, parameters: Any, /) -> object: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
def __or__(self, other: Any, /) -> _SpecialForm: ...
def __ror__(self, other: Any, /) -> _SpecialForm: ...

Union: _SpecialForm
Generic: _SpecialForm
Expand Down Expand Up @@ -273,8 +273,8 @@ if sys.version_info >= (3, 11):
def __init__(self, name: str) -> None: ...

def __iter__(self) -> Any: ...
def __typing_subst__(self, arg: Never) -> Never: ...
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
def __typing_subst__(self, arg: Never, /) -> Never: ...
def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
if sys.version_info >= (3, 14):
@property
def evaluate_default(self) -> EvaluateFunc | None: ...
Expand All @@ -289,7 +289,7 @@ if sys.version_info >= (3, 10):
else:
def __init__(self, origin: ParamSpec) -> None: ...

def __eq__(self, other: object) -> bool: ...
def __eq__(self, other: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]

@final
Expand All @@ -301,7 +301,7 @@ if sys.version_info >= (3, 10):
else:
def __init__(self, origin: ParamSpec) -> None: ...

def __eq__(self, other: object) -> bool: ...
def __eq__(self, other: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]

@final
Expand Down Expand Up @@ -365,11 +365,11 @@ if sys.version_info >= (3, 10):
@property
def kwargs(self) -> ParamSpecKwargs: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Any) -> Any: ...
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
def __typing_subst__(self, arg: Any, /) -> Any: ...
def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...

def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
def __or__(self, right: Any, /) -> _SpecialForm: ...
def __ror__(self, left: Any, /) -> _SpecialForm: ...
if sys.version_info >= (3, 13):
def has_default(self) -> bool: ...
if sys.version_info >= (3, 14):
Expand All @@ -388,8 +388,8 @@ if sys.version_info >= (3, 10):
else:
def __call__(self, x: _T) -> _T: ...

def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
def __or__(self, other: Any, /) -> _SpecialForm: ...
def __ror__(self, other: Any, /) -> _SpecialForm: ...
__supertype__: type | NewType

else:
Expand Down Expand Up @@ -421,7 +421,7 @@ def type_check_only(func_or_cls: _FT) -> _FT: ...

class _Alias:
# Class for defining generic aliases for library types.
def __getitem__(self, typeargs: Any) -> Any: ...
def __getitem__(self, typeargs: Any, /) -> Any: ...

List = _Alias()
Dict = _Alias()
Expand Down Expand Up @@ -630,110 +630,110 @@ class Collection(Iterable[_T_co], Container[_T_co], 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) -> Sequence[_T_co]: ...
def __getitem__(self, index: slice, /) -> 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 __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) -> MutableSequence[_T]: ...
def __getitem__(self, index: slice, /) -> 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, value: Iterable[_T]) -> None: ...
def __setitem__(self, index: slice, 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) -> None: ...
def __delitem__(self, index: slice, /) -> None: ...
# Mixin methods
def append(self, value: _T) -> None: ...
def clear(self) -> 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 __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
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 __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 __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):
def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented
def __len__(self) -> int: ...

class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, item: object) -> bool: ...
def __and__(self, other: Iterable[Any], /) -> set[tuple[_KT_co, _VT_co]]: ...
def __rand__(self, other: Iterable[_T], /) -> set[_T]: ...
def __contains__(self, item: object, /) -> bool: ...
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: Mapping[_KT_co, Any]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, key: object) -> bool: ...
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: Mapping[Any, _VT_co]) -> None: ... # undocumented
def __contains__(self, value: object) -> bool: ...
def __contains__(self, value: object, /) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...

class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
Expand Down Expand Up @@ -1013,7 +1013,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: _Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self, m: typing_extensions.Self, /) -> None: ...
def __delitem__(self, k: _Never) -> None: ...
def __delitem__(self, k: _Never, /) -> None: ...
def items(self) -> dict_items[str, object]: ...
def keys(self) -> dict_keys[str, object]: ...
def values(self) -> dict_values[str, object]: ...
Expand Down Expand Up @@ -1087,11 +1087,11 @@ else:
self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, recursive_guard: frozenset[str]
) -> Any | None: ... # AnnotationForm

def __eq__(self, other: object) -> bool: ...
def __eq__(self, other: object, /) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 11):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
def __or__(self, other: Any, /) -> _SpecialForm: ...
def __ror__(self, other: Any, /) -> _SpecialForm: ...

if sys.version_info >= (3, 10):
def is_typeddict(tp: object) -> bool: ...
Expand All @@ -1114,9 +1114,9 @@ if sys.version_info >= (3, 12):
# It's writable on types, but not on instances of TypeAliasType.
@property
def __module__(self) -> str | None: ... # type: ignore[override]
def __getitem__(self, parameters: Any) -> GenericAlias: ... # AnnotationForm
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
def __getitem__(self, parameters: Any, /) -> GenericAlias: ... # AnnotationForm
def __or__(self, right: Any, /) -> _SpecialForm: ...
def __ror__(self, left: Any, /) -> _SpecialForm: ...
if sys.version_info >= (3, 14):
@property
def evaluate_value(self) -> EvaluateFunc: ...
Expand Down
Loading