mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 03:11:16 +08:00
Supported repeated field containers for extensions (#5788)
See https://github.com/dropbox/mypy-protobuf/issues/244 for the inspiration for this. Repeated extensions are allowed by protobuf, and they generate to extension values with repeated fields. Notably map fields (ScalarMap and MessageMap) are NOT allowed to be extension values - producing errors as such - so those are omitted. testproto/test_extensions3.proto:19:6: Map fields are not allowed to be extensions.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
from typing import Any, Generic, Iterator, Text, TypeVar, Union
|
||||
|
||||
from google.protobuf.descriptor import FieldDescriptor
|
||||
from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer
|
||||
from google.protobuf.message import Message
|
||||
|
||||
_ContainerMessageT = TypeVar("_ContainerMessageT", bound=Message)
|
||||
_ExtenderMessageT = TypeVar("_ExtenderMessageT", bound=Union[Message, bool, int, float, Text, bytes])
|
||||
_ExtenderMessageT = TypeVar(
|
||||
"_ExtenderMessageT",
|
||||
bound=Union[Message, RepeatedScalarFieldContainer[Any], RepeatedCompositeFieldContainer[Any], bool, int, float, Text, bytes],
|
||||
)
|
||||
|
||||
class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user