Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions stubs/protobuf/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ google.protobuf.message.Message.Extensions
# Has *args that would fail at runtime with any positional argument
google.protobuf.internal.containers.BaseContainer.sort

# Stubbed as static method, but actually exists as a property that's
# a function. Typeshed's typing is more useful
google.protobuf.service.Service.GetDescriptor

# These are deliberately omitted in the stub.
# The classes can't be constructed directly anyway,
# so the signatures of their constructors are somewhat irrelevant.
Expand Down
4 changes: 2 additions & 2 deletions stubs/protobuf/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Using an exact number in the specifier for scripts/sync_protobuf/google_protobuf.py
# When updating, also re-run the script
version = "~=5.29.1"
version = "~=6.30.2"
upstream_repository = "https://github.com/protocolbuffers/protobuf"
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`)."
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`)."
partial_stub = true

[tool.stubtest]
Expand Down
4 changes: 3 additions & 1 deletion stubs/protobuf/google/protobuf/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__: str
from typing import Final

__version__: Final[str]
79 changes: 68 additions & 11 deletions stubs/protobuf/google/protobuf/descriptor_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,16 @@ class FileDescriptorProto(google.protobuf.message.Message):
The supported values are "proto2", "proto3", and "editions".

If `edition` is present, this value must be "editions".
WARNING: This field should only be used by protobuf plugins or special
cases like the proto compiler. Other uses are discouraged and
developers should rely on the protoreflect APIs for their client language.
"""
edition: global___Edition.ValueType
"""The edition of the proto file."""
"""The edition of the proto file.
WARNING: This field should only be used by protobuf plugins or special
cases like the proto compiler. Other uses are discouraged and
developers should rely on the protoreflect APIs for their client language.
"""
@property
def dependency(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
"""Names of files imported by this file."""
Expand Down Expand Up @@ -982,7 +989,11 @@ class FileOptions(google.protobuf.message.Message):
"""
@property
def features(self) -> global___FeatureSet:
"""Any features defined in the specific edition."""
"""Any features defined in the specific edition.
WARNING: This field should only be used by protobuf plugins or special
cases like the proto compiler. Other uses are discouraged and
developers should rely on the protoreflect APIs for their client language.
"""

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

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

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

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

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

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

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

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

class _EnforceNamingStyle:
ValueType = typing.NewType("ValueType", builtins.int)
V: typing_extensions.TypeAlias = ValueType

class _EnforceNamingStyleEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._EnforceNamingStyle.ValueType], builtins.type):
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
ENFORCE_NAMING_STYLE_UNKNOWN: FeatureSet._EnforceNamingStyle.ValueType # 0
STYLE2024: FeatureSet._EnforceNamingStyle.ValueType # 1
STYLE_LEGACY: FeatureSet._EnforceNamingStyle.ValueType # 2

class EnforceNamingStyle(_EnforceNamingStyle, metaclass=_EnforceNamingStyleEnumTypeWrapper): ...
ENFORCE_NAMING_STYLE_UNKNOWN: FeatureSet.EnforceNamingStyle.ValueType # 0
STYLE2024: FeatureSet.EnforceNamingStyle.ValueType # 1
STYLE_LEGACY: FeatureSet.EnforceNamingStyle.ValueType # 2

FIELD_PRESENCE_FIELD_NUMBER: builtins.int
ENUM_TYPE_FIELD_NUMBER: builtins.int
REPEATED_FIELD_ENCODING_FIELD_NUMBER: builtins.int
UTF8_VALIDATION_FIELD_NUMBER: builtins.int
MESSAGE_ENCODING_FIELD_NUMBER: builtins.int
JSON_FORMAT_FIELD_NUMBER: builtins.int
ENFORCE_NAMING_STYLE_FIELD_NUMBER: builtins.int
field_presence: global___FeatureSet.FieldPresence.ValueType
enum_type: global___FeatureSet.EnumType.ValueType
repeated_field_encoding: global___FeatureSet.RepeatedFieldEncoding.ValueType
utf8_validation: global___FeatureSet.Utf8Validation.ValueType
message_encoding: global___FeatureSet.MessageEncoding.ValueType
json_format: global___FeatureSet.JsonFormat.ValueType
enforce_naming_style: global___FeatureSet.EnforceNamingStyle.ValueType
def __init__(
self,
*,
Expand All @@ -1830,9 +1886,10 @@ class FeatureSet(google.protobuf.message.Message):
utf8_validation: global___FeatureSet.Utf8Validation.ValueType | None = ...,
message_encoding: global___FeatureSet.MessageEncoding.ValueType | None = ...,
json_format: global___FeatureSet.JsonFormat.ValueType | None = ...,
enforce_naming_style: global___FeatureSet.EnforceNamingStyle.ValueType | None = ...,
) -> None: ...
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: ...
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: ...
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: ...
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: ...

global___FeatureSet = FeatureSet

Expand Down
2 changes: 2 additions & 0 deletions stubs/protobuf/google/protobuf/internal/containers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ScalarMap(MutableMapping[_K, _ScalarV]):
def get(self, key: _K, default: None = None) -> _ScalarV | None: ...
@overload
def get(self, key: _K, default: _ScalarV | _T) -> _ScalarV | _T: ...
def setdefault(self, key: _K, value: _ScalarV | None = None) -> _ScalarV: ...
def MergeFrom(self, other: Self): ...
def InvalidateIterators(self) -> None: ...
def GetEntryClass(self) -> GeneratedProtocolMessageType: ...
Expand All @@ -96,6 +97,7 @@ class MessageMap(MutableMapping[_K, _MessageV]):
@overload
def get(self, key: _K, default: _MessageV | _T) -> _MessageV | _T: ...
def get_or_create(self, key: _K) -> _MessageV: ...
def setdefault(self, key: _K, value: _MessageV | None = None) -> _MessageV: ...
def MergeFrom(self, other: Self): ...
def InvalidateIterators(self) -> None: ...
def GetEntryClass(self) -> GeneratedProtocolMessageType: ...
2 changes: 0 additions & 2 deletions stubs/protobuf/google/protobuf/internal/decoder.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,3 @@ MESSAGE_SET_ITEM_TAG: bytes

def MessageSetItemDecoder(descriptor: Descriptor) -> _Decoder: ...
def MapDecoder(field_descriptor, new_default, is_message_map) -> _Decoder: ...

SkipField: Any
2 changes: 0 additions & 2 deletions stubs/protobuf/google/protobuf/message_factory.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ from google.protobuf.message import Message
class MessageFactory:
pool: Any
def __init__(self, pool: DescriptorPool | None = None) -> None: ...
def GetPrototype(self, descriptor: Descriptor) -> type[Message]: ...
def GetMessages(self, files: Iterable[str]) -> dict[str, type[Message]]: ...

def GetMessageClass(descriptor: Descriptor) -> type[Message]: ...
def GetMessageClassesForFiles(files: Iterable[str], pool: DescriptorPool) -> dict[str, type[Message]]: ...
Expand Down
3 changes: 0 additions & 3 deletions stubs/protobuf/google/protobuf/reflection.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
class GeneratedProtocolMessageType(type):
def __new__(cls, name, bases, dictionary): ...

def ParseMessage(descriptor, byte_str): ...
def MakeClass(descriptor): ...
39 changes: 0 additions & 39 deletions stubs/protobuf/google/protobuf/service.pyi

This file was deleted.

42 changes: 38 additions & 4 deletions stubs/protobuf/google/protobuf/wrappers_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Wrappers for primitive (non-message) types. These types are useful
for embedding primitives in the `google.protobuf.Any` type and for places
where we need to distinguish between the absence of a primitive
typed field and its default value.
Wrappers for primitive (non-message) types. These types were needed
for legacy reasons and are not recommended for use in new APIs.

Historically these wrappers were useful to have presence on proto3 primitive
fields, but proto3 syntax has been updated to support the `optional` keyword.
Using that keyword is now the strongly preferred way to add presence to
proto3 primitive fields.

A secondary usecase was to embed primitives in the `google.protobuf.Any`
type: it is now recommended that you embed your value in your own wrapper
message which can be specifically documented.

These wrappers have no meaningful use within repeated fields as they lack
the ability to detect presence on individual elements.
Expand All @@ -55,6 +62,9 @@ class DoubleValue(google.protobuf.message.Message):
"""Wrapper message for `double`.

The JSON representation for `DoubleValue` is JSON number.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -76,6 +86,9 @@ class FloatValue(google.protobuf.message.Message):
"""Wrapper message for `float`.

The JSON representation for `FloatValue` is JSON number.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -97,6 +110,9 @@ class Int64Value(google.protobuf.message.Message):
"""Wrapper message for `int64`.

The JSON representation for `Int64Value` is JSON string.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -118,6 +134,9 @@ class UInt64Value(google.protobuf.message.Message):
"""Wrapper message for `uint64`.

The JSON representation for `UInt64Value` is JSON string.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -139,6 +158,9 @@ class Int32Value(google.protobuf.message.Message):
"""Wrapper message for `int32`.

The JSON representation for `Int32Value` is JSON number.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -160,6 +182,9 @@ class UInt32Value(google.protobuf.message.Message):
"""Wrapper message for `uint32`.

The JSON representation for `UInt32Value` is JSON number.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -181,6 +206,9 @@ class BoolValue(google.protobuf.message.Message):
"""Wrapper message for `bool`.

The JSON representation for `BoolValue` is JSON `true` and `false`.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -202,6 +230,9 @@ class StringValue(google.protobuf.message.Message):
"""Wrapper message for `string`.

The JSON representation for `StringValue` is JSON string.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand All @@ -223,6 +254,9 @@ class BytesValue(google.protobuf.message.Message):
"""Wrapper message for `bytes`.

The JSON representation for `BytesValue` is JSON string.

Not recommended for use in new APIs, but still useful for legacy APIs and
has no plan to be removed.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor
Expand Down