protobuf 6.30.1__py3-none-any.whl → 6.31.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of protobuf might be problematic. Click here for more details.
- google/protobuf/__init__.py +1 -1
- google/protobuf/any.py +15 -1
- google/protobuf/any_pb2.py +4 -4
- google/protobuf/api_pb2.py +4 -4
- google/protobuf/compiler/plugin_pb2.py +4 -4
- google/protobuf/descriptor.py +15 -2
- google/protobuf/descriptor_pb2.py +259 -114
- google/protobuf/descriptor_pool.py +22 -8
- google/protobuf/duration_pb2.py +4 -4
- google/protobuf/empty_pb2.py +4 -4
- google/protobuf/field_mask_pb2.py +4 -4
- google/protobuf/internal/decoder.py +75 -23
- google/protobuf/internal/field_mask.py +3 -1
- google/protobuf/internal/python_edition_defaults.py +1 -1
- google/protobuf/internal/python_message.py +21 -18
- google/protobuf/internal/testing_refleaks.py +8 -2
- google/protobuf/internal/well_known_types.py +60 -43
- google/protobuf/json_format.py +4 -5
- google/protobuf/message_factory.py +16 -0
- google/protobuf/runtime_version.py +3 -3
- google/protobuf/source_context_pb2.py +4 -4
- google/protobuf/struct_pb2.py +4 -4
- google/protobuf/text_format.py +11 -7
- google/protobuf/timestamp_pb2.py +4 -4
- google/protobuf/type_pb2.py +4 -4
- google/protobuf/wrappers_pb2.py +4 -4
- {protobuf-6.30.1.dist-info → protobuf-6.31.0rc1.dist-info}/METADATA +1 -1
- protobuf-6.31.0rc1.dist-info/RECORD +58 -0
- protobuf-6.30.1.dist-info/RECORD +0 -58
- {protobuf-6.30.1.dist-info → protobuf-6.31.0rc1.dist-info}/LICENSE +0 -0
- {protobuf-6.30.1.dist-info → protobuf-6.31.0rc1.dist-info}/WHEEL +0 -0
google/protobuf/__init__.py
CHANGED
google/protobuf/any.py
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
"""Contains the Any helper APIs."""
|
|
9
9
|
|
|
10
|
-
from typing import Optional
|
|
10
|
+
from typing import Optional, TypeVar
|
|
11
11
|
|
|
12
12
|
from google.protobuf import descriptor
|
|
13
13
|
from google.protobuf.message import Message
|
|
@@ -15,6 +15,9 @@ from google.protobuf.message import Message
|
|
|
15
15
|
from google.protobuf.any_pb2 import Any
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
_MessageT = TypeVar('_MessageT', bound=Message)
|
|
19
|
+
|
|
20
|
+
|
|
18
21
|
def pack(
|
|
19
22
|
msg: Message,
|
|
20
23
|
type_url_prefix: Optional[str] = 'type.googleapis.com/',
|
|
@@ -31,6 +34,17 @@ def unpack(any_msg: Any, msg: Message) -> bool:
|
|
|
31
34
|
return any_msg.Unpack(msg=msg)
|
|
32
35
|
|
|
33
36
|
|
|
37
|
+
def unpack_as(any_msg: Any, message_type: type[_MessageT]) -> _MessageT:
|
|
38
|
+
unpacked = message_type()
|
|
39
|
+
if unpack(any_msg, unpacked):
|
|
40
|
+
return unpacked
|
|
41
|
+
else:
|
|
42
|
+
raise TypeError(
|
|
43
|
+
f'Attempted to unpack {type_name(any_msg)} to'
|
|
44
|
+
f' {message_type.__qualname__}'
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
34
48
|
def type_name(any_msg: Any) -> str:
|
|
35
49
|
return any_msg.TypeName()
|
|
36
50
|
|
google/protobuf/any_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/any.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.31.0-rc1
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,9 +12,9 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'',
|
|
15
|
+
31,
|
|
16
|
+
0,
|
|
17
|
+
'-rc1',
|
|
18
18
|
'google/protobuf/any.proto'
|
|
19
19
|
)
|
|
20
20
|
# @@protoc_insertion_point(imports)
|
google/protobuf/api_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/api.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.31.0-rc1
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,9 +12,9 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'',
|
|
15
|
+
31,
|
|
16
|
+
0,
|
|
17
|
+
'-rc1',
|
|
18
18
|
'google/protobuf/api.proto'
|
|
19
19
|
)
|
|
20
20
|
# @@protoc_insertion_point(imports)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/compiler/plugin.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.31.0-rc1
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,9 +12,9 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'',
|
|
15
|
+
31,
|
|
16
|
+
0,
|
|
17
|
+
'-rc1',
|
|
18
18
|
'google/protobuf/compiler/plugin.proto'
|
|
19
19
|
)
|
|
20
20
|
# @@protoc_insertion_point(imports)
|
google/protobuf/descriptor.py
CHANGED
|
@@ -728,6 +728,19 @@ class FieldDescriptor(DescriptorBase):
|
|
|
728
728
|
return FieldDescriptor.LABEL_REQUIRED
|
|
729
729
|
return self._label
|
|
730
730
|
|
|
731
|
+
@property
|
|
732
|
+
def is_required(self):
|
|
733
|
+
"""Returns if the field is required."""
|
|
734
|
+
return (
|
|
735
|
+
self._GetFeatures().field_presence
|
|
736
|
+
== _FEATURESET_FIELD_PRESENCE_LEGACY_REQUIRED
|
|
737
|
+
)
|
|
738
|
+
|
|
739
|
+
@property
|
|
740
|
+
def is_repeated(self):
|
|
741
|
+
"""Returns if the field is repeated."""
|
|
742
|
+
return self._label == FieldDescriptor.LABEL_REPEATED
|
|
743
|
+
|
|
731
744
|
@property
|
|
732
745
|
def camelcase_name(self):
|
|
733
746
|
"""Camelcase name of this field.
|
|
@@ -746,7 +759,7 @@ class FieldDescriptor(DescriptorBase):
|
|
|
746
759
|
Raises:
|
|
747
760
|
RuntimeError: singular field that is not linked with message nor file.
|
|
748
761
|
"""
|
|
749
|
-
if self.
|
|
762
|
+
if self.is_repeated:
|
|
750
763
|
return False
|
|
751
764
|
if (
|
|
752
765
|
self.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE
|
|
@@ -763,7 +776,7 @@ class FieldDescriptor(DescriptorBase):
|
|
|
763
776
|
@property
|
|
764
777
|
def is_packed(self):
|
|
765
778
|
"""Returns if the field is packed."""
|
|
766
|
-
if self.
|
|
779
|
+
if not self.is_repeated:
|
|
767
780
|
return False
|
|
768
781
|
field_type = self.type
|
|
769
782
|
if (field_type == FieldDescriptor.TYPE_STRING or
|