protobuf: Bring back Message.Extensions (#7154)

This commit is contained in:
Nipunn Koorapati
2022-02-08 04:51:41 -08:00
committed by GitHub
parent 494481a0ae
commit 96a09f6a35
2 changed files with 16 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ from _typeshed import Self
from typing import Any, Sequence, TypeVar
from .descriptor import Descriptor, FieldDescriptor
from .internal.extension_dict import _ExtensionFieldDescriptor
from .internal.extension_dict import _ExtensionDict, _ExtensionFieldDescriptor
class Error(Exception): ...
class DecodeError(Error): ...
@@ -28,6 +28,9 @@ class Message:
# The TypeVar must be bound to `Message` or we get mypy errors, so we cannot use `Self` for `HasExtension` & `ClearExtension`
def HasExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> bool: ...
def ClearExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> None: ...
# The TypeVar must be bound to `Message` or we get mypy errors, so we cannot use `Self` for `Extensions`
@property
def Extensions(self: _M) -> _ExtensionDict[_M]: ...
def ByteSize(self) -> int: ...
@classmethod
def FromString(cls: type[Self], s: bytes) -> Self: ...