Skip to content

Commit c994e2d

Browse files
donBarbosAvasam
andauthored
Bump protobuf to ~=6.30.2 (#13922)
Co-authored-by: Avasam <[email protected]>
1 parent f26b41b commit c994e2d

File tree

10 files changed

+113
-68
lines changed

10 files changed

+113
-68
lines changed

stubs/protobuf/@tests/stubtest_allowlist.txt

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ google.protobuf.message.Message.Extensions
1616
# Has *args that would fail at runtime with any positional argument
1717
google.protobuf.internal.containers.BaseContainer.sort
1818

19-
# Stubbed as static method, but actually exists as a property that's
20-
# a function. Typeshed's typing is more useful
21-
google.protobuf.service.Service.GetDescriptor
22-
2319
# These are deliberately omitted in the stub.
2420
# The classes can't be constructed directly anyway,
2521
# so the signatures of their constructors are somewhat irrelevant.

stubs/protobuf/METADATA.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Using an exact number in the specifier for scripts/sync_protobuf/google_protobuf.py
22
# When updating, also re-run the script
3-
version = "~=5.29.1"
3+
version = "~=6.30.2"
44
upstream_repository = "https://github.com/protocolbuffers/protobuf"
5-
extra_description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 28.1 on [protobuf v29.1](https://github.com/protocolbuffers/protobuf/releases/tag/v29.1) (python `protobuf==5.29.1`)."
5+
extra_description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 29.0 on [protobuf v30.2](https://github.com/protocolbuffers/protobuf/releases/tag/v30.2) (python `protobuf==6.30.2`)."
66
partial_stub = true
77

88
[tool.stubtest]
+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__: str
1+
from typing import Final
2+
3+
__version__: Final[str]

stubs/protobuf/google/protobuf/descriptor_pb2.pyi

+68-11
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,16 @@ class FileDescriptorProto(google.protobuf.message.Message):
151151
The supported values are "proto2", "proto3", and "editions".
152152
153153
If `edition` is present, this value must be "editions".
154+
WARNING: This field should only be used by protobuf plugins or special
155+
cases like the proto compiler. Other uses are discouraged and
156+
developers should rely on the protoreflect APIs for their client language.
154157
"""
155158
edition: global___Edition.ValueType
156-
"""The edition of the proto file."""
159+
"""The edition of the proto file.
160+
WARNING: This field should only be used by protobuf plugins or special
161+
cases like the proto compiler. Other uses are discouraged and
162+
developers should rely on the protoreflect APIs for their client language.
163+
"""
157164
@property
158165
def dependency(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
159166
"""Names of files imported by this file."""
@@ -982,7 +989,11 @@ class FileOptions(google.protobuf.message.Message):
982989
"""
983990
@property
984991
def features(self) -> global___FeatureSet:
985-
"""Any features defined in the specific edition."""
992+
"""Any features defined in the specific edition.
993+
WARNING: This field should only be used by protobuf plugins or special
994+
cases like the proto compiler. Other uses are discouraged and
995+
developers should rely on the protoreflect APIs for their client language.
996+
"""
986997

987998
@property
988999
def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]:
@@ -1099,7 +1110,11 @@ class MessageOptions(google.protobuf.message.Message):
10991110
"""
11001111
@property
11011112
def features(self) -> global___FeatureSet:
1102-
"""Any features defined in the specific edition."""
1113+
"""Any features defined in the specific edition.
1114+
WARNING: This field should only be used by protobuf plugins or special
1115+
cases like the proto compiler. Other uses are discouraged and
1116+
developers should rely on the protoreflect APIs for their client language.
1117+
"""
11031118

11041119
@property
11051120
def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]:
@@ -1378,7 +1393,11 @@ class FieldOptions(google.protobuf.message.Message):
13781393
def edition_defaults(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FieldOptions.EditionDefault]: ...
13791394
@property
13801395
def features(self) -> global___FeatureSet:
1381-
"""Any features defined in the specific edition."""
1396+
"""Any features defined in the specific edition.
1397+
WARNING: This field should only be used by protobuf plugins or special
1398+
cases like the proto compiler. Other uses are discouraged and
1399+
developers should rely on the protoreflect APIs for their client language.
1400+
"""
13821401

13831402
@property
13841403
def feature_support(self) -> global___FieldOptions.FeatureSupport: ...
@@ -1417,7 +1436,11 @@ class OneofOptions(google.protobuf.message.Message):
14171436
UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int
14181437
@property
14191438
def features(self) -> global___FeatureSet:
1420-
"""Any features defined in the specific edition."""
1439+
"""Any features defined in the specific edition.
1440+
WARNING: This field should only be used by protobuf plugins or special
1441+
cases like the proto compiler. Other uses are discouraged and
1442+
developers should rely on the protoreflect APIs for their client language.
1443+
"""
14211444

14221445
@property
14231446
def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]:
@@ -1463,7 +1486,11 @@ class EnumOptions(google.protobuf.message.Message):
14631486
"""
14641487
@property
14651488
def features(self) -> global___FeatureSet:
1466-
"""Any features defined in the specific edition."""
1489+
"""Any features defined in the specific edition.
1490+
WARNING: This field should only be used by protobuf plugins or special
1491+
cases like the proto compiler. Other uses are discouraged and
1492+
developers should rely on the protoreflect APIs for their client language.
1493+
"""
14671494

14681495
@property
14691496
def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]:
@@ -1505,7 +1532,11 @@ class EnumValueOptions(google.protobuf.message.Message):
15051532
"""
15061533
@property
15071534
def features(self) -> global___FeatureSet:
1508-
"""Any features defined in the specific edition."""
1535+
"""Any features defined in the specific edition.
1536+
WARNING: This field should only be used by protobuf plugins or special
1537+
cases like the proto compiler. Other uses are discouraged and
1538+
developers should rely on the protoreflect APIs for their client language.
1539+
"""
15091540

15101541
@property
15111542
def feature_support(self) -> global___FieldOptions.FeatureSupport:
@@ -1549,7 +1580,11 @@ class ServiceOptions(google.protobuf.message.Message):
15491580
"""
15501581
@property
15511582
def features(self) -> global___FeatureSet:
1552-
"""Any features defined in the specific edition."""
1583+
"""Any features defined in the specific edition.
1584+
WARNING: This field should only be used by protobuf plugins or special
1585+
cases like the proto compiler. Other uses are discouraged and
1586+
developers should rely on the protoreflect APIs for their client language.
1587+
"""
15531588

15541589
@property
15551590
def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]:
@@ -1613,7 +1648,11 @@ class MethodOptions(google.protobuf.message.Message):
16131648
idempotency_level: global___MethodOptions.IdempotencyLevel.ValueType
16141649
@property
16151650
def features(self) -> global___FeatureSet:
1616-
"""Any features defined in the specific edition."""
1651+
"""Any features defined in the specific edition.
1652+
WARNING: This field should only be used by protobuf plugins or special
1653+
cases like the proto compiler. Other uses are discouraged and
1654+
developers should rely on the protoreflect APIs for their client language.
1655+
"""
16171656

16181657
@property
16191658
def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]:
@@ -1809,18 +1848,35 @@ class FeatureSet(google.protobuf.message.Message):
18091848
ALLOW: FeatureSet.JsonFormat.ValueType # 1
18101849
LEGACY_BEST_EFFORT: FeatureSet.JsonFormat.ValueType # 2
18111850

1851+
class _EnforceNamingStyle:
1852+
ValueType = typing.NewType("ValueType", builtins.int)
1853+
V: typing_extensions.TypeAlias = ValueType
1854+
1855+
class _EnforceNamingStyleEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._EnforceNamingStyle.ValueType], builtins.type):
1856+
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
1857+
ENFORCE_NAMING_STYLE_UNKNOWN: FeatureSet._EnforceNamingStyle.ValueType # 0
1858+
STYLE2024: FeatureSet._EnforceNamingStyle.ValueType # 1
1859+
STYLE_LEGACY: FeatureSet._EnforceNamingStyle.ValueType # 2
1860+
1861+
class EnforceNamingStyle(_EnforceNamingStyle, metaclass=_EnforceNamingStyleEnumTypeWrapper): ...
1862+
ENFORCE_NAMING_STYLE_UNKNOWN: FeatureSet.EnforceNamingStyle.ValueType # 0
1863+
STYLE2024: FeatureSet.EnforceNamingStyle.ValueType # 1
1864+
STYLE_LEGACY: FeatureSet.EnforceNamingStyle.ValueType # 2
1865+
18121866
FIELD_PRESENCE_FIELD_NUMBER: builtins.int
18131867
ENUM_TYPE_FIELD_NUMBER: builtins.int
18141868
REPEATED_FIELD_ENCODING_FIELD_NUMBER: builtins.int
18151869
UTF8_VALIDATION_FIELD_NUMBER: builtins.int
18161870
MESSAGE_ENCODING_FIELD_NUMBER: builtins.int
18171871
JSON_FORMAT_FIELD_NUMBER: builtins.int
1872+
ENFORCE_NAMING_STYLE_FIELD_NUMBER: builtins.int
18181873
field_presence: global___FeatureSet.FieldPresence.ValueType
18191874
enum_type: global___FeatureSet.EnumType.ValueType
18201875
repeated_field_encoding: global___FeatureSet.RepeatedFieldEncoding.ValueType
18211876
utf8_validation: global___FeatureSet.Utf8Validation.ValueType
18221877
message_encoding: global___FeatureSet.MessageEncoding.ValueType
18231878
json_format: global___FeatureSet.JsonFormat.ValueType
1879+
enforce_naming_style: global___FeatureSet.EnforceNamingStyle.ValueType
18241880
def __init__(
18251881
self,
18261882
*,
@@ -1830,9 +1886,10 @@ class FeatureSet(google.protobuf.message.Message):
18301886
utf8_validation: global___FeatureSet.Utf8Validation.ValueType | None = ...,
18311887
message_encoding: global___FeatureSet.MessageEncoding.ValueType | None = ...,
18321888
json_format: global___FeatureSet.JsonFormat.ValueType | None = ...,
1889+
enforce_naming_style: global___FeatureSet.EnforceNamingStyle.ValueType | None = ...,
18331890
) -> None: ...
1834-
def HasField(self, field_name: typing.Literal["enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "repeated_field_encoding", b"repeated_field_encoding", "utf8_validation", b"utf8_validation"]) -> builtins.bool: ...
1835-
def ClearField(self, field_name: typing.Literal["enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "repeated_field_encoding", b"repeated_field_encoding", "utf8_validation", b"utf8_validation"]) -> None: ...
1891+
def HasField(self, field_name: typing.Literal["enforce_naming_style", b"enforce_naming_style", "enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "repeated_field_encoding", b"repeated_field_encoding", "utf8_validation", b"utf8_validation"]) -> builtins.bool: ...
1892+
def ClearField(self, field_name: typing.Literal["enforce_naming_style", b"enforce_naming_style", "enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "repeated_field_encoding", b"repeated_field_encoding", "utf8_validation", b"utf8_validation"]) -> None: ...
18361893

18371894
global___FeatureSet = FeatureSet
18381895

stubs/protobuf/google/protobuf/internal/containers.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class ScalarMap(MutableMapping[_K, _ScalarV]):
7373
def get(self, key: _K, default: None = None) -> _ScalarV | None: ...
7474
@overload
7575
def get(self, key: _K, default: _ScalarV | _T) -> _ScalarV | _T: ...
76+
def setdefault(self, key: _K, value: _ScalarV | None = None) -> _ScalarV: ...
7677
def MergeFrom(self, other: Self): ...
7778
def InvalidateIterators(self) -> None: ...
7879
def GetEntryClass(self) -> GeneratedProtocolMessageType: ...
@@ -96,6 +97,7 @@ class MessageMap(MutableMapping[_K, _MessageV]):
9697
@overload
9798
def get(self, key: _K, default: _MessageV | _T) -> _MessageV | _T: ...
9899
def get_or_create(self, key: _K) -> _MessageV: ...
100+
def setdefault(self, key: _K, value: _MessageV | None = None) -> _MessageV: ...
99101
def MergeFrom(self, other: Self): ...
100102
def InvalidateIterators(self) -> None: ...
101103
def GetEntryClass(self) -> GeneratedProtocolMessageType: ...

stubs/protobuf/google/protobuf/internal/decoder.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,3 @@ MESSAGE_SET_ITEM_TAG: bytes
5959

6060
def MessageSetItemDecoder(descriptor: Descriptor) -> _Decoder: ...
6161
def MapDecoder(field_descriptor, new_default, is_message_map) -> _Decoder: ...
62-
63-
SkipField: Any

stubs/protobuf/google/protobuf/message_factory.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ from google.protobuf.message import Message
99
class MessageFactory:
1010
pool: Any
1111
def __init__(self, pool: DescriptorPool | None = None) -> None: ...
12-
def GetPrototype(self, descriptor: Descriptor) -> type[Message]: ...
13-
def GetMessages(self, files: Iterable[str]) -> dict[str, type[Message]]: ...
1412

1513
def GetMessageClass(descriptor: Descriptor) -> type[Message]: ...
1614
def GetMessageClassesForFiles(files: Iterable[str], pool: DescriptorPool) -> dict[str, type[Message]]: ...
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
class GeneratedProtocolMessageType(type):
22
def __new__(cls, name, bases, dictionary): ...
3-
4-
def ParseMessage(descriptor, byte_str): ...
5-
def MakeClass(descriptor): ...

stubs/protobuf/google/protobuf/service.pyi

-39
This file was deleted.

stubs/protobuf/google/protobuf/wrappers_pb2.pyi

+38-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3131
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3232
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
34-
Wrappers for primitive (non-message) types. These types are useful
35-
for embedding primitives in the `google.protobuf.Any` type and for places
36-
where we need to distinguish between the absence of a primitive
37-
typed field and its default value.
34+
Wrappers for primitive (non-message) types. These types were needed
35+
for legacy reasons and are not recommended for use in new APIs.
36+
37+
Historically these wrappers were useful to have presence on proto3 primitive
38+
fields, but proto3 syntax has been updated to support the `optional` keyword.
39+
Using that keyword is now the strongly preferred way to add presence to
40+
proto3 primitive fields.
41+
42+
A secondary usecase was to embed primitives in the `google.protobuf.Any`
43+
type: it is now recommended that you embed your value in your own wrapper
44+
message which can be specifically documented.
3845
3946
These wrappers have no meaningful use within repeated fields as they lack
4047
the ability to detect presence on individual elements.
@@ -55,6 +62,9 @@ class DoubleValue(google.protobuf.message.Message):
5562
"""Wrapper message for `double`.
5663
5764
The JSON representation for `DoubleValue` is JSON number.
65+
66+
Not recommended for use in new APIs, but still useful for legacy APIs and
67+
has no plan to be removed.
5868
"""
5969

6070
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -76,6 +86,9 @@ class FloatValue(google.protobuf.message.Message):
7686
"""Wrapper message for `float`.
7787
7888
The JSON representation for `FloatValue` is JSON number.
89+
90+
Not recommended for use in new APIs, but still useful for legacy APIs and
91+
has no plan to be removed.
7992
"""
8093

8194
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -97,6 +110,9 @@ class Int64Value(google.protobuf.message.Message):
97110
"""Wrapper message for `int64`.
98111
99112
The JSON representation for `Int64Value` is JSON string.
113+
114+
Not recommended for use in new APIs, but still useful for legacy APIs and
115+
has no plan to be removed.
100116
"""
101117

102118
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -118,6 +134,9 @@ class UInt64Value(google.protobuf.message.Message):
118134
"""Wrapper message for `uint64`.
119135
120136
The JSON representation for `UInt64Value` is JSON string.
137+
138+
Not recommended for use in new APIs, but still useful for legacy APIs and
139+
has no plan to be removed.
121140
"""
122141

123142
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -139,6 +158,9 @@ class Int32Value(google.protobuf.message.Message):
139158
"""Wrapper message for `int32`.
140159
141160
The JSON representation for `Int32Value` is JSON number.
161+
162+
Not recommended for use in new APIs, but still useful for legacy APIs and
163+
has no plan to be removed.
142164
"""
143165

144166
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -160,6 +182,9 @@ class UInt32Value(google.protobuf.message.Message):
160182
"""Wrapper message for `uint32`.
161183
162184
The JSON representation for `UInt32Value` is JSON number.
185+
186+
Not recommended for use in new APIs, but still useful for legacy APIs and
187+
has no plan to be removed.
163188
"""
164189

165190
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -181,6 +206,9 @@ class BoolValue(google.protobuf.message.Message):
181206
"""Wrapper message for `bool`.
182207
183208
The JSON representation for `BoolValue` is JSON `true` and `false`.
209+
210+
Not recommended for use in new APIs, but still useful for legacy APIs and
211+
has no plan to be removed.
184212
"""
185213

186214
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -202,6 +230,9 @@ class StringValue(google.protobuf.message.Message):
202230
"""Wrapper message for `string`.
203231
204232
The JSON representation for `StringValue` is JSON string.
233+
234+
Not recommended for use in new APIs, but still useful for legacy APIs and
235+
has no plan to be removed.
205236
"""
206237

207238
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -223,6 +254,9 @@ class BytesValue(google.protobuf.message.Message):
223254
"""Wrapper message for `bytes`.
224255
225256
The JSON representation for `BytesValue` is JSON string.
257+
258+
Not recommended for use in new APIs, but still useful for legacy APIs and
259+
has no plan to be removed.
226260
"""
227261

228262
DESCRIPTOR: google.protobuf.descriptor.Descriptor

0 commit comments

Comments
 (0)