Skip to content

Commit a99fdbf

Browse files
authored
[protobuf] Bump to 7.35.1 (#16255)
1 parent a1499c5 commit a99fdbf

8 files changed

Lines changed: 148 additions & 164 deletions

File tree

stubs/protobuf/METADATA.toml

Lines changed: 2 additions & 2 deletions
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 = "~=7.34.1"
3+
version = "~=7.35.1"
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 34.1 on [protobuf v34.1](https://github.com/protocolbuffers/protobuf/releases/tag/v34.1) (python `protobuf==7.34.1`)."
5+
extra-description = "Partially generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) and libprotoc 35.1 on [protobuf v35.1](https://github.com/protocolbuffers/protobuf/releases/tag/v35.1) (python `protobuf==7.35.1`)."
66
partial-stub = true
77

88
[tool.stubtest]

stubs/protobuf/google/protobuf/any_pb2.pyi

Lines changed: 57 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -46,126 +46,72 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t
4646
"""`Any` contains an arbitrary serialized protocol buffer message along with a
4747
URL that describes the type of the serialized message.
4848
49-
Protobuf library provides support to pack/unpack Any values in the form
50-
of utility functions or additional generated methods of the Any type.
51-
52-
Example 1: Pack and unpack a message in C++.
53-
54-
Foo foo = ...;
55-
Any any;
56-
any.PackFrom(foo);
57-
...
58-
if (any.UnpackTo(&foo)) {
59-
...
60-
}
61-
62-
Example 2: Pack and unpack a message in Java.
63-
64-
Foo foo = ...;
65-
Any any = Any.pack(foo);
66-
...
67-
if (any.is(Foo.class)) {
68-
foo = any.unpack(Foo.class);
69-
}
70-
// or ...
71-
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
72-
foo = any.unpack(Foo.getDefaultInstance());
73-
}
74-
75-
Example 3: Pack and unpack a message in Python.
76-
77-
foo = Foo(...)
78-
any = Any()
79-
any.Pack(foo)
80-
...
81-
if any.Is(Foo.DESCRIPTOR):
82-
any.Unpack(foo)
83-
...
84-
85-
Example 4: Pack and unpack a message in Go
86-
87-
foo := &pb.Foo{...}
88-
any, err := anypb.New(foo)
89-
if err != nil {
90-
...
91-
}
92-
...
93-
foo := &pb.Foo{}
94-
if err := any.UnmarshalTo(foo); err != nil {
95-
...
96-
}
97-
98-
The pack methods provided by protobuf library will by default use
99-
'type.googleapis.com/full.type.name' as the type URL and the unpack
100-
methods only use the fully qualified type name after the last '/'
101-
in the type URL, for example "foo.bar.com/x/y.z" will yield type
102-
name "y.z".
103-
104-
JSON
105-
====
106-
The JSON representation of an `Any` value uses the regular
107-
representation of the deserialized, embedded message, with an
108-
additional field `@type` which contains the type URL. Example:
109-
110-
package google.profile;
111-
message Person {
112-
string first_name = 1;
113-
string last_name = 2;
114-
}
115-
116-
{
117-
"@type": "type.googleapis.com/google.profile.Person",
118-
"firstName": <string>,
119-
"lastName": <string>
120-
}
121-
122-
If the embedded message type is well-known and has a custom JSON
123-
representation, that representation will be embedded adding a field
124-
`value` which holds the custom JSON in addition to the `@type`
125-
field. Example (for message [google.protobuf.Duration][]):
126-
127-
{
128-
"@type": "type.googleapis.com/google.protobuf.Duration",
129-
"value": "1.212s"
130-
}
49+
In its binary encoding, an `Any` is an ordinary message; but in other wire
50+
forms like JSON, it has a special encoding. The format of the type URL is
51+
described on the `type_url` field.
52+
53+
Protobuf APIs provide utilities to interact with `Any` values:
54+
55+
- A 'pack' operation accepts a message and constructs a generic `Any` wrapper
56+
around it.
57+
- An 'unpack' operation reads the content of an `Any` message, either into an
58+
existing message or a new one. Unpack operations must check the type of the
59+
value they unpack against the declared `type_url`.
60+
- An 'is' operation decides whether an `Any` contains a message of the given
61+
type, i.e. whether it can 'unpack' that type.
62+
63+
The JSON format representation of an `Any` follows one of these cases:
64+
65+
- For types without special-cased JSON encodings, the JSON format
66+
representation of the `Any` is the same as that of the message, with an
67+
additional `@type` field which contains the type URL.
68+
- For types with special-cased JSON encodings (typically called 'well-known'
69+
types, listed in https://protobuf.dev/programming-guides/json/#any), the
70+
JSON format representation has a key `@type` which contains the type URL
71+
and a key `value` which contains the JSON-serialized value.
72+
73+
The text format representation of an `Any` is like a message with one field
74+
whose name is the type URL in brackets. For example, an `Any` containing a
75+
`foo.Bar` message may be written `[type.googleapis.com/foo.Bar] { a: 2 }`.
13176
"""
13277

13378
DESCRIPTOR: google.protobuf.descriptor.Descriptor
13479

13580
TYPE_URL_FIELD_NUMBER: builtins.int
13681
VALUE_FIELD_NUMBER: builtins.int
13782
type_url: builtins.str
138-
"""A URL/resource name that uniquely identifies the type of the serialized
139-
protocol buffer message. This string must contain at least
140-
one "/" character. The last segment of the URL's path must represent
141-
the fully qualified name of the type (as in
142-
`path/google.protobuf.Duration`). The name should be in a canonical form
143-
(e.g., leading "." is not accepted).
144-
145-
In practice, teams usually precompile into the binary all types that they
146-
expect it to use in the context of Any. However, for URLs which use the
147-
scheme `http`, `https`, or no scheme, one can optionally set up a type
148-
server that maps type URLs to message definitions as follows:
149-
150-
* If no scheme is provided, `https` is assumed.
151-
* An HTTP GET on the URL must yield a [google.protobuf.Type][]
152-
value in binary format, or produce an error.
153-
* Applications are allowed to cache lookup results based on the
154-
URL, or have them precompiled into a binary to avoid any
155-
lookup. Therefore, binary compatibility needs to be preserved
156-
on changes to types. (Use versioned type names to manage
157-
breaking changes.)
158-
159-
Note: this functionality is not currently available in the official
160-
protobuf release, and it is not used for type URLs beginning with
161-
type.googleapis.com. As of May 2023, there are no widely used type server
162-
implementations and no plans to implement one.
163-
164-
Schemes other than `http`, `https` (or the empty scheme) might be
165-
used with implementation specific semantics.
83+
"""Identifies the type of the serialized Protobuf message with a URI reference
84+
consisting of a prefix ending in a slash and the fully-qualified type name.
85+
86+
Example: type.googleapis.com/google.protobuf.StringValue
87+
88+
This string must contain at least one `/` character, and the content after
89+
the last `/` must be the fully-qualified name of the type in canonical
90+
form, without a leading dot. Do not write a scheme on these URI references
91+
so that clients do not attempt to contact them.
92+
93+
The prefix is arbitrary and Protobuf implementations are expected to
94+
simply strip off everything up to and including the last `/` to identify
95+
the type. `type.googleapis.com/` is a common default prefix that some
96+
legacy implementations require. This prefix does not indicate the origin of
97+
the type, and URIs containing it are not expected to respond to any
98+
requests.
99+
100+
All type URL strings must be legal URI references with the additional
101+
restriction (for the text format) that the content of the reference
102+
must consist only of alphanumeric characters, percent-encoded escapes, and
103+
characters in the following set (not including the outer backticks):
104+
`/-.~_!$&()*+,;=`. Despite our allowing percent encodings, implementations
105+
should not unescape them to prevent confusion with existing parsers. For
106+
example, `type.googleapis.com%2FFoo` should be rejected.
107+
108+
In the original design of `Any`, the possibility of launching a type
109+
resolution service at these type URLs was considered but Protobuf never
110+
implemented one and considers contacting these URLs to be problematic and
111+
a potential security issue. Do not attempt to contact type URLs.
166112
"""
167113
value: builtins.bytes
168-
"""Must be a valid serialized protocol buffer of the above specified type."""
114+
"""Holds a Protobuf serialization of the type described by type_url."""
169115
def __init__(self, *, type_url: builtins.str | None = ..., value: builtins.bytes | None = ...) -> None: ...
170116
def ClearField(self, field_name: typing.Literal["type_url", b"type_url", "value", b"value"]) -> None: ...
171117

stubs/protobuf/google/protobuf/descriptor_pb2.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class _EditionEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTy
5252
comparison.
5353
"""
5454
EDITION_2024: _Edition.ValueType # 1001
55+
EDITION_2026: _Edition.ValueType # 1002
56+
EDITION_UNSTABLE: _Edition.ValueType # 9999
57+
"""A placeholder edition for developing and testing unscheduled features."""
5558
EDITION_1_TEST_ONLY: _Edition.ValueType # 1
5659
"""Placeholder editions for testing feature resolution. These should not be
5760
used or relied on outside of tests.
@@ -88,6 +91,9 @@ should not be depended on, but they will always be time-ordered for easy
8891
comparison.
8992
"""
9093
EDITION_2024: Edition.ValueType # 1001
94+
EDITION_2026: Edition.ValueType # 1002
95+
EDITION_UNSTABLE: Edition.ValueType # 9999
96+
"""A placeholder edition for developing and testing unscheduled features."""
9197
EDITION_1_TEST_ONLY: Edition.ValueType # 1
9298
"""Placeholder editions for testing feature resolution. These should not be
9399
used or relied on outside of tests.
@@ -1649,6 +1655,7 @@ class FieldOptions(google.protobuf.message.Message):
16491655
EDITION_DEPRECATED_FIELD_NUMBER: builtins.int
16501656
DEPRECATION_WARNING_FIELD_NUMBER: builtins.int
16511657
EDITION_REMOVED_FIELD_NUMBER: builtins.int
1658+
REMOVAL_ERROR_FIELD_NUMBER: builtins.int
16521659
edition_introduced: global___Edition.ValueType
16531660
"""The edition that this feature was first available in. In editions
16541661
earlier than this one, the default assigned to EDITION_LEGACY will be
@@ -1667,13 +1674,18 @@ class FieldOptions(google.protobuf.message.Message):
16671674
this one, the last default assigned will be used, and proto files will
16681675
not be able to override it.
16691676
"""
1677+
removal_error: builtins.str
1678+
"""The removal error text if this feature is used after the edition it was
1679+
removed in.
1680+
"""
16701681
def __init__(
16711682
self,
16721683
*,
16731684
edition_introduced: global___Edition.ValueType | None = ...,
16741685
edition_deprecated: global___Edition.ValueType | None = ...,
16751686
deprecation_warning: builtins.str | None = ...,
16761687
edition_removed: global___Edition.ValueType | None = ...,
1688+
removal_error: builtins.str | None = ...,
16771689
) -> None: ...
16781690
def HasField(
16791691
self,
@@ -1686,6 +1698,8 @@ class FieldOptions(google.protobuf.message.Message):
16861698
b"edition_introduced",
16871699
"edition_removed",
16881700
b"edition_removed",
1701+
"removal_error",
1702+
b"removal_error",
16891703
],
16901704
) -> builtins.bool: ...
16911705
def ClearField(
@@ -1699,6 +1713,8 @@ class FieldOptions(google.protobuf.message.Message):
16991713
b"edition_introduced",
17001714
"edition_removed",
17011715
b"edition_removed",
1716+
"removal_error",
1717+
b"removal_error",
17021718
],
17031719
) -> None: ...
17041720

@@ -2460,11 +2476,13 @@ class FeatureSet(google.protobuf.message.Message):
24602476
ENFORCE_NAMING_STYLE_UNKNOWN: FeatureSet._EnforceNamingStyle.ValueType # 0
24612477
STYLE2024: FeatureSet._EnforceNamingStyle.ValueType # 1
24622478
STYLE_LEGACY: FeatureSet._EnforceNamingStyle.ValueType # 2
2479+
STYLE2026: FeatureSet._EnforceNamingStyle.ValueType # 3
24632480

24642481
class EnforceNamingStyle(_EnforceNamingStyle, metaclass=_EnforceNamingStyleEnumTypeWrapper): ...
24652482
ENFORCE_NAMING_STYLE_UNKNOWN: FeatureSet.EnforceNamingStyle.ValueType # 0
24662483
STYLE2024: FeatureSet.EnforceNamingStyle.ValueType # 1
24672484
STYLE_LEGACY: FeatureSet.EnforceNamingStyle.ValueType # 2
2485+
STYLE2026: FeatureSet.EnforceNamingStyle.ValueType # 3
24682486

24692487
@typing.final
24702488
class VisibilityFeature(google.protobuf.message.Message):

stubs/protobuf/google/protobuf/field_mask_pb2.pyi

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,24 +157,22 @@ class FieldMask(google.protobuf.message.Message, google.protobuf.internal.well_k
157157
An implementation may provide options to override this default behavior for
158158
repeated and message fields.
159159
160-
In order to reset a field's value to the default, the field must
161-
be in the mask and set to the default value in the provided resource.
162-
Hence, in order to reset all fields of a resource, provide a default
163-
instance of the resource and set all fields in the mask, or do
164-
not provide a mask as described below.
165-
166-
If a field mask is not present on update, the operation applies to
167-
all fields (as if a field mask of all fields has been specified).
168-
Note that in the presence of schema evolution, this may mean that
169-
fields the client does not know and has therefore not filled into
170-
the request will be reset to their default. If this is unwanted
171-
behavior, a specific service may require a client to always specify
172-
a field mask, producing an error if not.
173-
174-
As with get operations, the location of the resource which
175-
describes the updated values in the request message depends on the
176-
operation kind. In any case, the effect of the field mask is
177-
required to be honored by the API.
160+
Note that libraries which implement FieldMask resolution have various
161+
different behaviors in the face of empty masks or the special "*" mask.
162+
When implementing a service you should confirm these cases have the
163+
appropriate behavior in the underlying FieldMask library that you desire,
164+
and you may need to special case those cases in your application code if
165+
the underlying field mask library behavior differs from your intended
166+
service semantics.
167+
168+
Update methods implementing https://google.aip.dev/134
169+
- MUST support the special value * meaning "full replace"
170+
- MUST treat an omitted field mask as "replace fields which are present".
171+
172+
Other methods implementing https://google.aip.dev/157
173+
- SHOULD support the special value "*" to mean "get all".
174+
- MUST treat an omitted field mask to mean "get all", unless otherwise
175+
documented.
178176
179177
## Considerations for HTTP REST
180178

stubs/protobuf/google/protobuf/json_format.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ def MessageToJson(
1919
descriptor_pool: DescriptorPool | None = None,
2020
ensure_ascii: bool = True,
2121
always_print_fields_with_no_presence: bool = False,
22+
*,
23+
unquote_int64_if_possible: bool = False,
2224
) -> str: ...
2325
def MessageToDict(
2426
message: Message,
2527
always_print_fields_with_no_presence: bool = False,
2628
preserving_proto_field_name: bool = False,
2729
use_integers_for_enums: bool = False,
2830
descriptor_pool: DescriptorPool | None = None,
31+
*,
32+
unquote_int64_if_possible: bool = False,
2933
) -> dict[str, Any]: ...
3034
def Parse(
3135
text: bytes | str,

0 commit comments

Comments
 (0)