Skip to content

Remove FieldDescriptor fallback for protobuf extension methods #5754

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 2 commits into from
Jul 10, 2021
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
16 changes: 1 addition & 15 deletions stubs/protobuf/google/protobuf/internal/extension_dict.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Generic, Iterator, TypeVar, overload
from typing import Any, Generic, Iterator, TypeVar

from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.message import Message
Expand All @@ -10,27 +10,13 @@ class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _Ex

class _ExtensionDict(Generic[_ContainerMessageT]):
def __init__(self, extended_message: _ContainerMessageT) -> None: ...
# Dummy fallback overloads with FieldDescriptor are for backward compatibility with
# mypy-protobuf <= 1.23. We can drop them a few months after 1.24 releases.
@overload
def __getitem__(
self, extension_handle: _ExtensionFieldDescriptor[_ContainerMessageT, _ExtenderMessageT]
) -> _ExtenderMessageT: ...
@overload
def __getitem__(self, extension_handle: FieldDescriptor) -> Any: ...
@overload
def __setitem__(
self, extension_handle: _ExtensionFieldDescriptor[_ContainerMessageT, _ExtenderMessageT], value: _ExtenderMessageT
) -> None: ...
@overload
def __setitem__(self, extension_handle: FieldDescriptor, value: Any) -> None: ...
@overload
def __delitem__(self, extension_handle: _ExtensionFieldDescriptor[_ContainerMessageT, _ExtenderMessageT]) -> None: ...
@overload
def __delitem__(self, extension_handle: FieldDescriptor) -> None: ...
@overload
def __contains__(self, extension_handle: _ExtensionFieldDescriptor[_ContainerMessageT, _ExtenderMessageT]) -> bool: ...
@overload
def __contains__(self, extension_handle: FieldDescriptor) -> bool: ...
def __iter__(self) -> Iterator[_ExtensionFieldDescriptor[_ContainerMessageT, Any]]: ...
def __len__(self) -> int: ...
10 changes: 1 addition & 9 deletions stubs/protobuf/google/protobuf/message.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Any, ByteString, Sequence, Tuple, Type, TypeVar, Union, overload
from typing import Any, ByteString, Sequence, Tuple, Type, TypeVar, Union

from .descriptor import Descriptor, FieldDescriptor
from .internal.extension_dict import _ExtensionDict, _ExtensionFieldDescriptor
Expand Down Expand Up @@ -30,16 +30,8 @@ class Message:
def SerializeToString(self, deterministic: bool = ...) -> bytes: ...
def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ...
def ListFields(self) -> Sequence[Tuple[FieldDescriptor, Any]]: ...
# Dummy fallback overloads with FieldDescriptor are for backward compatibility with
# mypy-protobuf <= 1.23. We can drop them a few months after 1.24 releases.
@overload
def HasExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> bool: ...
@overload
def HasExtension(self, extension_handle: FieldDescriptor) -> bool: ...
@overload
def ClearExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> None: ...
@overload
def ClearExtension(self, extension_handle: FieldDescriptor) -> None: ...
def ByteSize(self) -> int: ...
@classmethod
def FromString(cls: Type[_M], s: _Serialized) -> _M: ...
Expand Down