Skip to content
Merged
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
11 changes: 8 additions & 3 deletions stubs/protobuf/google/protobuf/internal/containers.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
from collections.abc import Callable, Iterable, Iterator, MutableMapping, MutableSequence, Sequence
from typing import Any, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self

Expand All @@ -25,12 +25,13 @@ class BaseContainer(Sequence[_T]):
def __hash__(self) -> int: ...
# Same as list.sort, the extra sort_function kwarg errors in Python 3
def sort(self, *, key: Callable[[_T], Any] | None = None, reverse: bool = False) -> None: ...
def reverse(self) -> None: ...
@overload
def __getitem__(self, key: SupportsIndex) -> _T: ...
@overload
def __getitem__(self, key: slice) -> list[_T]: ...

class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]):
class RepeatedScalarFieldContainer(BaseContainer[_ScalarV], MutableSequence[_ScalarV]):
__slots__ = ["_type_checker"]
def __init__(self, message_listener: MessageListener, type_checker: _ValueChecker[_ScalarV]) -> None: ...
def append(self, value: _ScalarV) -> None: ...
Expand All @@ -46,7 +47,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]):
def __delitem__(self, key: int | slice) -> None: ...
def __eq__(self, other: object) -> bool: ...

class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]):
class RepeatedCompositeFieldContainer(BaseContainer[_MessageV], MutableSequence[_MessageV]):
__slots__ = ["_message_descriptor"]
def __init__(self, message_listener: MessageListener, message_descriptor: Descriptor) -> None: ...
def add(self, **kwargs: Any) -> _MessageV: ...
Expand All @@ -56,6 +57,10 @@ class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]):
def MergeFrom(self, other: Self | Iterable[_MessageV]) -> None: ...
def remove(self, elem: _MessageV) -> None: ...
def pop(self, key: int = -1) -> _MessageV: ...
@overload
def __setitem__(self, key: int, value: _MessageV) -> None: ...
@overload
def __setitem__(self, key: slice, value: Iterable[_MessageV]) -> None: ...
def __delitem__(self, key: int | slice) -> None: ...
def __eq__(self, other: object) -> bool: ...

Expand Down