From e97953674e434e86b9927cf49dffffa85a496f15 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 Apr 2024 13:06:48 -0400 Subject: [PATCH 01/14] Bump protobuf to v22 --- scripts/generate_proto_stubs.sh | 17 +- stubs/protobuf/METADATA.toml | 2 +- stubs/protobuf/google/protobuf/any_pb2.pyi | 5 +- .../google/protobuf/compiler/plugin_pb2.pyi | 3 - .../google/protobuf/descriptor_pb2.pyi | 165 +++++++++++++++--- .../google/protobuf/timestamp_pb2.pyi | 2 - .../protobuf/google/protobuf/wrappers_pb2.pyi | 30 ++++ 7 files changed, 187 insertions(+), 37 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 88c36bef7250..3cf6617b9588 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -11,8 +11,7 @@ set -ex -o pipefail # followed by committing the changes to typeshed # # Update these two variables when rerunning script -PROTOBUF_VERSION=21.8 -PYTHON_PROTOBUF_VERSION=4.21.8 +PROTOBUF_VERSION=22.0 MYPY_PROTOBUF_VERSION=3.5.0 if uname -a | grep Darwin; then @@ -23,10 +22,10 @@ else fi REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)" TMP_DIR="$(mktemp -d)" -PYTHON_PROTOBUF_FILENAME="protobuf-python-${PYTHON_PROTOBUF_VERSION}.zip" -PROTOC_FILENAME="protoc-${PROTOBUF_VERSION}-${PLAT}-x86_64.zip" -PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/$PROTOC_FILENAME" -PYTHON_PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/$PYTHON_PROTOBUF_FILENAME" +PYTHON_PROTOBUF_FILENAME="protobuf-$PROTOBUF_VERSION.zip" +PROTOC_FILENAME="protoc-$PROTOBUF_VERSION-$PLAT-x86_64.zip" +PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/$PROTOC_FILENAME" +PYTHON_PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/$PYTHON_PROTOBUF_FILENAME" cd "$TMP_DIR" echo "Working in $TMP_DIR" @@ -39,7 +38,7 @@ unzip "$PROTOC_FILENAME" -d protoc_install # Fetch protoc-python (which contains all the .proto files) wget "$PYTHON_PROTOBUF_URL" unzip "$PYTHON_PROTOBUF_FILENAME" -PYTHON_PROTOBUF_DIR="protobuf-$PYTHON_PROTOBUF_VERSION" +PYTHON_PROTOBUF_DIR="protobuf-$PROTOBUF_VERSION" # Prepare virtualenv VENV=venv @@ -74,6 +73,8 @@ protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="re # applies autofixes (which will result in a nonzero exit code) pre-commit run --files "$REPO_ROOT/stubs/protobuf" || true +PYTHON_PROTOBUF_VERSION=$(jq -r '.[] | .languages.python' "$PYTHON_PROTOBUF_DIR/version.json") + sed --in-place="" \ - "s/extra_description = .*$/extra_description = \"Generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on protobuf==$PYTHON_PROTOBUF_VERSION\"/" \ + "s/extra_description = .*$/extra_description = \"Generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on [protobuf v$PROTOBUF_VERSION](https:\/\/github.com\/protocolbuffers\/protobuf\/releases\/tag\/v$PROTOBUF_VERSION) (python protobuf==$PYTHON_PROTOBUF_VERSION)\"/" \ "$REPO_ROOT/stubs/protobuf/METADATA.toml" diff --git a/stubs/protobuf/METADATA.toml b/stubs/protobuf/METADATA.toml index 7ee1107f0357..eb204322fede 100644 --- a/stubs/protobuf/METADATA.toml +++ b/stubs/protobuf/METADATA.toml @@ -1,6 +1,6 @@ version = "4.24.*" upstream_repository = "https://github.com/protocolbuffers/protobuf" -extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on protobuf==4.21.8" +extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v22.0](https://github.com/protocolbuffers/protobuf/releases/tag/v22.0) (python protobuf==4.22.0)" partial_stub = true [tool.stubtest] diff --git a/stubs/protobuf/google/protobuf/any_pb2.pyi b/stubs/protobuf/google/protobuf/any_pb2.pyi index e9108a01f236..de5fe82679a0 100644 --- a/stubs/protobuf/google/protobuf/any_pb2.pyi +++ b/stubs/protobuf/google/protobuf/any_pb2.pyi @@ -66,6 +66,10 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } Example 3: Pack and unpack a message in Python. @@ -96,7 +100,6 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t in the type URL, for example "foo.bar.com/x/y.z" will yield type name "y.z". - JSON The JSON representation of an `Any` value uses the regular diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index 0c7ed03c2a00..6fe9f85fdab9 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -3,9 +3,6 @@ isort:skip_file Author: kenton@google.com (Kenton Varda) -WARNING: The plugin interface is currently EXPERIMENTAL and is subject to - change. - protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is just a program that reads a CodeGeneratorRequest from stdin and writes a CodeGeneratorResponse to stdout. diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index 53257ff489d8..b542543ef070 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -64,6 +64,7 @@ class FileDescriptorProto(google.protobuf.message.Message): OPTIONS_FIELD_NUMBER: builtins.int SOURCE_CODE_INFO_FIELD_NUMBER: builtins.int SYNTAX_FIELD_NUMBER: builtins.int + EDITION_FIELD_NUMBER: builtins.int name: builtins.str """file name, relative to root of source tree""" package: builtins.str @@ -99,8 +100,12 @@ class FileDescriptorProto(google.protobuf.message.Message): """ syntax: builtins.str """The syntax of the proto file. - The supported values are "proto2" and "proto3". + The supported values are "proto2", "proto3", and "editions". + + If `edition` is present, this value must be "editions". """ + edition: builtins.str + """The edition of the proto file, which is an opaque string.""" def __init__( self, *, @@ -116,9 +121,10 @@ class FileDescriptorProto(google.protobuf.message.Message): options: global___FileOptions | None = ..., source_code_info: global___SourceCodeInfo | None = ..., syntax: builtins.str | None = ..., + edition: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options", "package", b"package", "source_code_info", b"source_code_info", "syntax", b"syntax"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["dependency", b"dependency", "enum_type", b"enum_type", "extension", b"extension", "message_type", b"message_type", "name", b"name", "options", b"options", "package", b"package", "public_dependency", b"public_dependency", "service", b"service", "source_code_info", b"source_code_info", "syntax", b"syntax", "weak_dependency", b"weak_dependency"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "name", b"name", "options", b"options", "package", b"package", "source_code_info", b"source_code_info", "syntax", b"syntax"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["dependency", b"dependency", "edition", b"edition", "enum_type", b"enum_type", "extension", b"extension", "message_type", b"message_type", "name", b"name", "options", b"options", "package", b"package", "public_dependency", b"public_dependency", "service", b"service", "source_code_info", b"source_code_info", "syntax", b"syntax", "weak_dependency", b"weak_dependency"]) -> None: ... global___FileDescriptorProto = FileDescriptorProto @@ -837,6 +843,7 @@ class MessageOptions(google.protobuf.message.Message): NO_STANDARD_DESCRIPTOR_ACCESSOR_FIELD_NUMBER: builtins.int DEPRECATED_FIELD_NUMBER: builtins.int MAP_ENTRY_FIELD_NUMBER: builtins.int + DEPRECATED_LEGACY_JSON_FIELD_CONFLICTS_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int message_set_wire_format: builtins.bool """Set true to use the old proto1 MessageSet wire format for extensions. @@ -870,7 +877,11 @@ class MessageOptions(google.protobuf.message.Message): this is a formalization for deprecating messages. """ map_entry: builtins.bool - """Whether the message is an automatically generated map entry type for the + """NOTE: Do not set the option in .proto files. Always use the maps syntax + instead. The option should only be implicitly set by the proto compiler + parser. + + Whether the message is an automatically generated map entry type for the maps field. For maps fields: @@ -887,10 +898,18 @@ class MessageOptions(google.protobuf.message.Message): use a native map in the target language to hold the keys and values. The reflection APIs in such implementations still need to work as if the field is a repeated message field. + """ + deprecated_legacy_json_field_conflicts: builtins.bool + """Enable the legacy handling of JSON field name conflicts. This lowercases + and strips underscored from the fields before comparison in proto3 only. + The new behavior takes `json_name` into account and applies to proto2 as + well. - NOTE: Do not set the option in .proto files. Always use the maps syntax - instead. The option should only be implicitly set by the proto compiler - parser. + This should only be used as a temporary measure against broken builds due + to the change in behavior for JSON field name conflicts. + + TODO(b/261750190) This is legacy behavior we plan to remove once downstream + teams have had time to migrate. """ @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: @@ -902,10 +921,11 @@ class MessageOptions(google.protobuf.message.Message): no_standard_descriptor_accessor: builtins.bool | None = ..., deprecated: builtins.bool | None = ..., map_entry: builtins.bool | None = ..., + deprecated_legacy_json_field_conflicts: builtins.bool | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___MessageOptions = MessageOptions @@ -951,6 +971,61 @@ class FieldOptions(google.protobuf.message.Message): JS_NUMBER: FieldOptions.JSType.ValueType # 2 """Use JavaScript numbers.""" + class _OptionRetention: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _OptionRetentionEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FieldOptions._OptionRetention.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + RETENTION_UNKNOWN: FieldOptions._OptionRetention.ValueType # 0 + RETENTION_RUNTIME: FieldOptions._OptionRetention.ValueType # 1 + RETENTION_SOURCE: FieldOptions._OptionRetention.ValueType # 2 + + class OptionRetention(_OptionRetention, metaclass=_OptionRetentionEnumTypeWrapper): + """If set to RETENTION_SOURCE, the option will be omitted from the binary. + Note: as of January 2023, support for this is in progress and does not yet + have an effect (b/264593489). + """ + + RETENTION_UNKNOWN: FieldOptions.OptionRetention.ValueType # 0 + RETENTION_RUNTIME: FieldOptions.OptionRetention.ValueType # 1 + RETENTION_SOURCE: FieldOptions.OptionRetention.ValueType # 2 + + class _OptionTargetType: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _OptionTargetTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FieldOptions._OptionTargetType.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + TARGET_TYPE_UNKNOWN: FieldOptions._OptionTargetType.ValueType # 0 + TARGET_TYPE_FILE: FieldOptions._OptionTargetType.ValueType # 1 + TARGET_TYPE_EXTENSION_RANGE: FieldOptions._OptionTargetType.ValueType # 2 + TARGET_TYPE_MESSAGE: FieldOptions._OptionTargetType.ValueType # 3 + TARGET_TYPE_FIELD: FieldOptions._OptionTargetType.ValueType # 4 + TARGET_TYPE_ONEOF: FieldOptions._OptionTargetType.ValueType # 5 + TARGET_TYPE_ENUM: FieldOptions._OptionTargetType.ValueType # 6 + TARGET_TYPE_ENUM_ENTRY: FieldOptions._OptionTargetType.ValueType # 7 + TARGET_TYPE_SERVICE: FieldOptions._OptionTargetType.ValueType # 8 + TARGET_TYPE_METHOD: FieldOptions._OptionTargetType.ValueType # 9 + + class OptionTargetType(_OptionTargetType, metaclass=_OptionTargetTypeEnumTypeWrapper): + """This indicates the types of entities that the field may apply to when used + as an option. If it is unset, then the field may be freely used as an + option on any kind of entity. Note: as of January 2023, support for this is + in progress and does not yet have an effect (b/264593489). + """ + + TARGET_TYPE_UNKNOWN: FieldOptions.OptionTargetType.ValueType # 0 + TARGET_TYPE_FILE: FieldOptions.OptionTargetType.ValueType # 1 + TARGET_TYPE_EXTENSION_RANGE: FieldOptions.OptionTargetType.ValueType # 2 + TARGET_TYPE_MESSAGE: FieldOptions.OptionTargetType.ValueType # 3 + TARGET_TYPE_FIELD: FieldOptions.OptionTargetType.ValueType # 4 + TARGET_TYPE_ONEOF: FieldOptions.OptionTargetType.ValueType # 5 + TARGET_TYPE_ENUM: FieldOptions.OptionTargetType.ValueType # 6 + TARGET_TYPE_ENUM_ENTRY: FieldOptions.OptionTargetType.ValueType # 7 + TARGET_TYPE_SERVICE: FieldOptions.OptionTargetType.ValueType # 8 + TARGET_TYPE_METHOD: FieldOptions.OptionTargetType.ValueType # 9 + CTYPE_FIELD_NUMBER: builtins.int PACKED_FIELD_NUMBER: builtins.int JSTYPE_FIELD_NUMBER: builtins.int @@ -958,6 +1033,9 @@ class FieldOptions(google.protobuf.message.Message): UNVERIFIED_LAZY_FIELD_NUMBER: builtins.int DEPRECATED_FIELD_NUMBER: builtins.int WEAK_FIELD_NUMBER: builtins.int + DEBUG_REDACT_FIELD_NUMBER: builtins.int + RETENTION_FIELD_NUMBER: builtins.int + TARGET_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int ctype: global___FieldOptions.CType.ValueType """The ctype option instructs the C++ code generator to use a different @@ -1003,7 +1081,6 @@ class FieldOptions(google.protobuf.message.Message): call from multiple threads concurrently, while non-const methods continue to require exclusive access. - Note that implementations may choose not to check required fields within a lazy sub-message. That is, calling IsInitialized() on the outer message may return true even if the inner message has missing required fields. @@ -1015,11 +1092,8 @@ class FieldOptions(google.protobuf.message.Message): check its required fields, regardless of whether or not the message has been parsed. - As of 2021, lazy does no correctness checks on the byte stream during - parsing. This may lead to crashes if and when an invalid byte stream is - finally parsed upon access. - - TODO(b/211906113): Enable validation on lazy fields. + As of May 2022, lazy verifies the contents of the byte stream during + parsing. An invalid byte stream will cause the overall parsing to fail. """ unverified_lazy: builtins.bool """unverified_lazy does no correctness checks on the byte stream. This should @@ -1034,6 +1108,12 @@ class FieldOptions(google.protobuf.message.Message): """ weak: builtins.bool """For Google-internal migration only. Do not use.""" + debug_redact: builtins.bool + """Indicate that the field value should not be printed out when using debug + formats, e.g. when the field contains sensitive credentials. + """ + retention: global___FieldOptions.OptionRetention.ValueType + target: global___FieldOptions.OptionTargetType.ValueType @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" @@ -1047,10 +1127,13 @@ class FieldOptions(google.protobuf.message.Message): unverified_lazy: builtins.bool | None = ..., deprecated: builtins.bool | None = ..., weak: builtins.bool | None = ..., + debug_redact: builtins.bool | None = ..., + retention: global___FieldOptions.OptionRetention.ValueType | None = ..., + target: global___FieldOptions.OptionTargetType.ValueType | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... global___FieldOptions = FieldOptions @@ -1077,6 +1160,7 @@ class EnumOptions(google.protobuf.message.Message): ALLOW_ALIAS_FIELD_NUMBER: builtins.int DEPRECATED_FIELD_NUMBER: builtins.int + DEPRECATED_LEGACY_JSON_FIELD_CONFLICTS_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int allow_alias: builtins.bool """Set this option to true to allow mapping different tag names to the same @@ -1088,6 +1172,14 @@ class EnumOptions(google.protobuf.message.Message): for the enum, or it will be completely ignored; in the very least, this is a formalization for deprecating enums. """ + deprecated_legacy_json_field_conflicts: builtins.bool + """Enable the legacy handling of JSON field name conflicts. This lowercases + and strips underscored from the fields before comparison in proto3 only. + The new behavior takes `json_name` into account and applies to proto2 as + well. + TODO(b/261750190) Remove this legacy behavior once downstream teams have + had time to migrate. + """ @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" @@ -1096,10 +1188,11 @@ class EnumOptions(google.protobuf.message.Message): *, allow_alias: builtins.bool | None = ..., deprecated: builtins.bool | None = ..., + deprecated_legacy_json_field_conflicts: builtins.bool | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___EnumOptions = EnumOptions @@ -1475,10 +1568,36 @@ class GeneratedCodeInfo(google.protobuf.message.Message): class Annotation(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + class _Semantic: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _SemanticEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[GeneratedCodeInfo.Annotation._Semantic.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + NONE: GeneratedCodeInfo.Annotation._Semantic.ValueType # 0 + """There is no effect or the effect is indescribable.""" + SET: GeneratedCodeInfo.Annotation._Semantic.ValueType # 1 + """The element is set or otherwise mutated.""" + ALIAS: GeneratedCodeInfo.Annotation._Semantic.ValueType # 2 + """An alias to the element is returned.""" + + class Semantic(_Semantic, metaclass=_SemanticEnumTypeWrapper): + """Represents the identified object's effect on the element in the original + .proto file. + """ + + NONE: GeneratedCodeInfo.Annotation.Semantic.ValueType # 0 + """There is no effect or the effect is indescribable.""" + SET: GeneratedCodeInfo.Annotation.Semantic.ValueType # 1 + """The element is set or otherwise mutated.""" + ALIAS: GeneratedCodeInfo.Annotation.Semantic.ValueType # 2 + """An alias to the element is returned.""" + PATH_FIELD_NUMBER: builtins.int SOURCE_FILE_FIELD_NUMBER: builtins.int BEGIN_FIELD_NUMBER: builtins.int END_FIELD_NUMBER: builtins.int + SEMANTIC_FIELD_NUMBER: builtins.int @property def path(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: """Identifies the element in the original source .proto file. This field @@ -1492,9 +1611,10 @@ class GeneratedCodeInfo(google.protobuf.message.Message): """ end: builtins.int """Identifies the ending offset in bytes in the generated code that - relates to the identified offset. The end offset should be one past + relates to the identified object. The end offset should be one past the last relevant byte (so the length of the text = end - begin). """ + semantic: global___GeneratedCodeInfo.Annotation.Semantic.ValueType def __init__( self, *, @@ -1502,9 +1622,10 @@ class GeneratedCodeInfo(google.protobuf.message.Message): source_file: builtins.str | None = ..., begin: builtins.int | None = ..., end: builtins.int | None = ..., + semantic: global___GeneratedCodeInfo.Annotation.Semantic.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["begin", b"begin", "end", b"end", "source_file", b"source_file"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["begin", b"begin", "end", b"end", "path", b"path", "source_file", b"source_file"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["begin", b"begin", "end", b"end", "semantic", b"semantic", "source_file", b"source_file"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["begin", b"begin", "end", b"end", "path", b"path", "semantic", b"semantic", "source_file", b"source_file"]) -> None: ... ANNOTATION_FIELD_NUMBER: builtins.int @property diff --git a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi index 916066f9af0f..6c1b1d7669c6 100644 --- a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi +++ b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi @@ -92,7 +92,6 @@ class Timestamp(google.protobuf.message.Message, google.protobuf.internal.well_k Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) .setNanos((int) ((millis % 1000) * 1000000)).build(); - Example 5: Compute Timestamp from Java `Instant.now()`. Instant now = Instant.now(); @@ -101,7 +100,6 @@ class Timestamp(google.protobuf.message.Message, google.protobuf.internal.well_k Timestamp.newBuilder().setSeconds(now.getEpochSecond()) .setNanos(now.getNano()).build(); - Example 6: Compute Timestamp from current time in Python. timestamp = Timestamp() diff --git a/stubs/protobuf/google/protobuf/wrappers_pb2.pyi b/stubs/protobuf/google/protobuf/wrappers_pb2.pyi index e3d3682d7edb..e87738c4d0f7 100644 --- a/stubs/protobuf/google/protobuf/wrappers_pb2.pyi +++ b/stubs/protobuf/google/protobuf/wrappers_pb2.pyi @@ -1,6 +1,36 @@ """ @generated by mypy-protobuf. Do not edit manually! isort:skip_file +Protocol Buffers - Google's data interchange format +Copyright 2008 Google Inc. All rights reserved. +https://developers.google.com/protocol-buffers/ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +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 From 1fab6fde61829f4f39d570ee3ea293de17c03fc5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 Apr 2024 13:12:16 -0400 Subject: [PATCH 02/14] Bump protobuf to v23 --- scripts/generate_proto_stubs.sh | 2 +- stubs/protobuf/METADATA.toml | 2 +- stubs/protobuf/google/protobuf/any_pb2.pyi | 6 +- stubs/protobuf/google/protobuf/api_pb2.pyi | 2 +- .../google/protobuf/descriptor_pb2.pyi | 107 +++++++++++++++++- stubs/protobuf/google/protobuf/struct_pb2.pyi | 2 +- .../google/protobuf/timestamp_pb2.pyi | 2 +- stubs/protobuf/google/protobuf/type_pb2.pyi | 16 ++- 8 files changed, 125 insertions(+), 14 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 3cf6617b9588..858eff2472d2 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -11,7 +11,7 @@ set -ex -o pipefail # followed by committing the changes to typeshed # # Update these two variables when rerunning script -PROTOBUF_VERSION=22.0 +PROTOBUF_VERSION=23.0 MYPY_PROTOBUF_VERSION=3.5.0 if uname -a | grep Darwin; then diff --git a/stubs/protobuf/METADATA.toml b/stubs/protobuf/METADATA.toml index eb204322fede..ef9831c8a416 100644 --- a/stubs/protobuf/METADATA.toml +++ b/stubs/protobuf/METADATA.toml @@ -1,6 +1,6 @@ version = "4.24.*" upstream_repository = "https://github.com/protocolbuffers/protobuf" -extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v22.0](https://github.com/protocolbuffers/protobuf/releases/tag/v22.0) (python protobuf==4.22.0)" +extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v23.0](https://github.com/protocolbuffers/protobuf/releases/tag/v23.0) (python protobuf==4.23.0)" partial_stub = true [tool.stubtest] diff --git a/stubs/protobuf/google/protobuf/any_pb2.pyi b/stubs/protobuf/google/protobuf/any_pb2.pyi index de5fe82679a0..f640918c8a48 100644 --- a/stubs/protobuf/google/protobuf/any_pb2.pyi +++ b/stubs/protobuf/google/protobuf/any_pb2.pyi @@ -71,7 +71,7 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -81,7 +81,7 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -101,7 +101,7 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t name "y.z". JSON - + ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: diff --git a/stubs/protobuf/google/protobuf/api_pb2.pyi b/stubs/protobuf/google/protobuf/api_pb2.pyi index 342c9307101d..925c1d6c22da 100644 --- a/stubs/protobuf/google/protobuf/api_pb2.pyi +++ b/stubs/protobuf/google/protobuf/api_pb2.pyi @@ -214,7 +214,7 @@ class Mixin(google.protobuf.message.Message): The mixin construct implies that all methods in `AccessControl` are also declared with same name and request/response types in `Storage`. A documentation generator or annotation processor will - see the effective `Storage.GetAcl` method after inheriting + see the effective `Storage.GetAcl` method after inherting documentation and annotations as follows: service Storage { diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index b542543ef070..fc5b450ff2fd 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -236,16 +236,95 @@ global___DescriptorProto = DescriptorProto class ExtensionRangeOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + class _VerificationState: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _VerificationStateEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[ExtensionRangeOptions._VerificationState.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + DECLARATION: ExtensionRangeOptions._VerificationState.ValueType # 0 + """All the extensions of the range must be declared.""" + UNVERIFIED: ExtensionRangeOptions._VerificationState.ValueType # 1 + + class VerificationState(_VerificationState, metaclass=_VerificationStateEnumTypeWrapper): + """The verification state of the extension range.""" + + DECLARATION: ExtensionRangeOptions.VerificationState.ValueType # 0 + """All the extensions of the range must be declared.""" + UNVERIFIED: ExtensionRangeOptions.VerificationState.ValueType # 1 + + @typing_extensions.final + class Declaration(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NUMBER_FIELD_NUMBER: builtins.int + FULL_NAME_FIELD_NUMBER: builtins.int + TYPE_FIELD_NUMBER: builtins.int + IS_REPEATED_FIELD_NUMBER: builtins.int + RESERVED_FIELD_NUMBER: builtins.int + REPEATED_FIELD_NUMBER: builtins.int + number: builtins.int + """The extension number declared within the extension range.""" + full_name: builtins.str + """The fully-qualified name of the extension field. There must be a leading + dot in front of the full name. + """ + type: builtins.str + """The fully-qualified type name of the extension field. Unlike + Metadata.type, Declaration.type must have a leading dot for messages + and enums. + """ + is_repeated: builtins.bool + """Deprecated. Please use "repeated".""" + reserved: builtins.bool + """If true, indicates that the number is reserved in the extension range, + and any extension field with the number will fail to compile. Set this + when a declared extension field is deleted. + """ + repeated: builtins.bool + """If true, indicates that the extension must be defined as repeated. + Otherwise the extension must be defined as optional. + """ + def __init__( + self, + *, + number: builtins.int | None = ..., + full_name: builtins.str | None = ..., + type: builtins.str | None = ..., + is_repeated: builtins.bool | None = ..., + reserved: builtins.bool | None = ..., + repeated: builtins.bool | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "is_repeated", b"is_repeated", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "is_repeated", b"is_repeated", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> None: ... + UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int + DECLARATION_FIELD_NUMBER: builtins.int + VERIFICATION_FIELD_NUMBER: builtins.int @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + @property + def declaration(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ExtensionRangeOptions.Declaration]: + """go/protobuf-stripping-extension-declarations + Like Metadata, but we use a repeated field to hold all extension + declarations. This should avoid the size increases of transforming a large + extension range into small ranges in generated binaries. + """ + verification: global___ExtensionRangeOptions.VerificationState.ValueType + """The verification state of the range. + TODO(b/278783756): flip the default to DECLARATION once all empty ranges + are marked as UNVERIFIED. + """ def __init__( self, *, uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., + declaration: collections.abc.Iterable[global___ExtensionRangeOptions.Declaration] | None = ..., + verification: global___ExtensionRangeOptions.VerificationState.ValueType | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["verification", b"verification"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["declaration", b"declaration", "uninterpreted_option", b"uninterpreted_option", "verification", b"verification"]) -> None: ... global___ExtensionRangeOptions = ExtensionRangeOptions @@ -942,12 +1021,26 @@ class FieldOptions(google.protobuf.message.Message): STRING: FieldOptions._CType.ValueType # 0 """Default mode.""" CORD: FieldOptions._CType.ValueType # 1 + """The option [ctype=CORD] may be applied to a non-repeated field of type + "bytes". It indicates that in C++, the data should be stored in a Cord + instead of a string. For very large strings, this may reduce memory + fragmentation. It may also allow better performance when parsing from a + Cord, or when parsing with aliasing enabled, as the parsed Cord may then + alias the original buffer. + """ STRING_PIECE: FieldOptions._CType.ValueType # 2 class CType(_CType, metaclass=_CTypeEnumTypeWrapper): ... STRING: FieldOptions.CType.ValueType # 0 """Default mode.""" CORD: FieldOptions.CType.ValueType # 1 + """The option [ctype=CORD] may be applied to a non-repeated field of type + "bytes". It indicates that in C++, the data should be stored in a Cord + instead of a string. For very large strings, this may reduce memory + fragmentation. It may also allow better performance when parsing from a + Cord, or when parsing with aliasing enabled, as the parsed Cord may then + alias the original buffer. + """ STRING_PIECE: FieldOptions.CType.ValueType # 2 class _JSType: @@ -1036,12 +1129,15 @@ class FieldOptions(google.protobuf.message.Message): DEBUG_REDACT_FIELD_NUMBER: builtins.int RETENTION_FIELD_NUMBER: builtins.int TARGET_FIELD_NUMBER: builtins.int + TARGETS_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int ctype: global___FieldOptions.CType.ValueType """The ctype option instructs the C++ code generator to use a different representation of the field than it normally would. See the specific - options below. This option is not yet implemented in the open source - release -- sorry, we'll try to include it in a future version! + options below. This option is only implemented to support use of + [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of + type "bytes" in the open source release -- sorry, we'll try to include + other types in a future version! """ packed: builtins.bool """The packed option can be enabled for repeated primitive fields to enable @@ -1115,6 +1211,8 @@ class FieldOptions(google.protobuf.message.Message): retention: global___FieldOptions.OptionRetention.ValueType target: global___FieldOptions.OptionTargetType.ValueType @property + def targets(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[global___FieldOptions.OptionTargetType.ValueType]: ... + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( @@ -1130,10 +1228,11 @@ class FieldOptions(google.protobuf.message.Message): debug_redact: builtins.bool | None = ..., retention: global___FieldOptions.OptionRetention.ValueType | None = ..., target: global___FieldOptions.OptionTargetType.ValueType | None = ..., + targets: collections.abc.Iterable[global___FieldOptions.OptionTargetType.ValueType] | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "targets", b"targets", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... global___FieldOptions = FieldOptions diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index b3716e5bab46..8b80de0c4b65 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -62,7 +62,7 @@ class NullValue(_NullValue, metaclass=_NullValueEnumTypeWrapper): """`NullValue` is a singleton enumeration to represent the null value for the `Value` type union. - The JSON representation for `NullValue` is JSON `null`. + The JSON representation for `NullValue` is JSON `null`. """ NULL_VALUE: NullValue.ValueType # 0 diff --git a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi index 6c1b1d7669c6..3f57f7602b6e 100644 --- a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi +++ b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi @@ -129,7 +129,7 @@ class Timestamp(google.protobuf.message.Message, google.protobuf.internal.well_k [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( - http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() ) to obtain a formatter capable of generating timestamps in this format. """ diff --git a/stubs/protobuf/google/protobuf/type_pb2.pyi b/stubs/protobuf/google/protobuf/type_pb2.pyi index dca4537bd447..60fcda720fc3 100644 --- a/stubs/protobuf/google/protobuf/type_pb2.pyi +++ b/stubs/protobuf/google/protobuf/type_pb2.pyi @@ -60,6 +60,8 @@ class _SyntaxEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTyp """Syntax `proto2`.""" SYNTAX_PROTO3: _Syntax.ValueType # 1 """Syntax `proto3`.""" + SYNTAX_EDITIONS: _Syntax.ValueType # 2 + """Syntax `editions`.""" class Syntax(_Syntax, metaclass=_SyntaxEnumTypeWrapper): """The syntax in which a protocol buffer element is defined.""" @@ -68,6 +70,8 @@ SYNTAX_PROTO2: Syntax.ValueType # 0 """Syntax `proto2`.""" SYNTAX_PROTO3: Syntax.ValueType # 1 """Syntax `proto3`.""" +SYNTAX_EDITIONS: Syntax.ValueType # 2 +"""Syntax `editions`.""" global___Syntax = Syntax @typing_extensions.final @@ -82,6 +86,7 @@ class Type(google.protobuf.message.Message): OPTIONS_FIELD_NUMBER: builtins.int SOURCE_CONTEXT_FIELD_NUMBER: builtins.int SYNTAX_FIELD_NUMBER: builtins.int + EDITION_FIELD_NUMBER: builtins.int name: builtins.str """The fully qualified message name.""" @property @@ -98,6 +103,8 @@ class Type(google.protobuf.message.Message): """The source context.""" syntax: global___Syntax.ValueType """The source syntax.""" + edition: builtins.str + """The source edition string, only valid when syntax is SYNTAX_EDITIONS.""" def __init__( self, *, @@ -107,9 +114,10 @@ class Type(google.protobuf.message.Message): options: collections.abc.Iterable[global___Option] | None = ..., source_context: google.protobuf.source_context_pb2.SourceContext | None = ..., syntax: global___Syntax.ValueType | None = ..., + edition: builtins.str | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal["source_context", b"source_context"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["fields", b"fields", "name", b"name", "oneofs", b"oneofs", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "fields", b"fields", "name", b"name", "oneofs", b"oneofs", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... global___Type = Type @@ -297,6 +305,7 @@ class Enum(google.protobuf.message.Message): OPTIONS_FIELD_NUMBER: builtins.int SOURCE_CONTEXT_FIELD_NUMBER: builtins.int SYNTAX_FIELD_NUMBER: builtins.int + EDITION_FIELD_NUMBER: builtins.int name: builtins.str """Enum type name.""" @property @@ -310,6 +319,8 @@ class Enum(google.protobuf.message.Message): """The source context.""" syntax: global___Syntax.ValueType """The source syntax.""" + edition: builtins.str + """The source edition string, only valid when syntax is SYNTAX_EDITIONS.""" def __init__( self, *, @@ -318,9 +329,10 @@ class Enum(google.protobuf.message.Message): options: collections.abc.Iterable[global___Option] | None = ..., source_context: google.protobuf.source_context_pb2.SourceContext | None = ..., syntax: global___Syntax.ValueType | None = ..., + edition: builtins.str | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal["source_context", b"source_context"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["enumvalue", b"enumvalue", "name", b"name", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "enumvalue", b"enumvalue", "name", b"name", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... global___Enum = Enum From 111a08380b766894815b87dca87c72248bfca5fd Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 Apr 2024 13:51:03 -0400 Subject: [PATCH 03/14] Bump protobuf to v24.4 and fix `pre-commit run --files` --- scripts/generate_proto_stubs.sh | 15 +- scripts/sync_tensorflow_protobuf_stubs.sh | 12 +- stubs/protobuf/METADATA.toml | 2 +- stubs/protobuf/google/protobuf/any_pb2.pyi | 3 +- .../google/protobuf/compiler/plugin_pb2.pyi | 17 +- .../google/protobuf/descriptor_pb2.pyi | 267 ++++++++++++++++-- 6 files changed, 275 insertions(+), 41 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 858eff2472d2..2568e2a8aaac 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -11,7 +11,7 @@ set -ex -o pipefail # followed by committing the changes to typeshed # # Update these two variables when rerunning script -PROTOBUF_VERSION=23.0 +PROTOBUF_VERSION=24.4 MYPY_PROTOBUF_VERSION=3.5.0 if uname -a | grep Darwin; then @@ -69,12 +69,17 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \ # shellcheck disable=SC2086 protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES -# use `|| true` so the script still continues even if a pre-commit hook -# applies autofixes (which will result in a nonzero exit code) -pre-commit run --files "$REPO_ROOT/stubs/protobuf" || true - PYTHON_PROTOBUF_VERSION=$(jq -r '.[] | .languages.python' "$PYTHON_PROTOBUF_DIR/version.json") sed --in-place="" \ "s/extra_description = .*$/extra_description = \"Generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on [protobuf v$PROTOBUF_VERSION](https:\/\/github.com\/protocolbuffers\/protobuf\/releases\/tag\/v$PROTOBUF_VERSION) (python protobuf==$PYTHON_PROTOBUF_VERSION)\"/" \ "$REPO_ROOT/stubs/protobuf/METADATA.toml" + +# Must be run in a git repository +cd $REPO_ROOT +# use `|| true` so the script still continues even if a pre-commit hook +# applies autofixes (which will result in a nonzero exit code) +pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf") || true +# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* +# and we don't need --unsafe-fixes to remove imports +ruff check "$REPO_ROOT/stubs/protobuf" --fix --exit-zero diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 29b603c810bd..f0a6324537a5 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -61,9 +61,6 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi -# use `|| true` so the script still continues even if a pre-commit hook -# applies autofixes (which will result in a nonzero exit code) -pre-commit run --files "$REPO_ROOT/stubs/tensorflow/tensorflow" || true sed --in-place="" \ "s/extra_description = .*$/extra_description = \"Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on tensorflow==$TENSORFLOW_VERSION\"/" \ @@ -71,3 +68,12 @@ sed --in-place="" \ # Cleanup last. If the script fails halfway, it's nice to be able to re-run it immediately rm -rf repository/ + +# Must be run in a git repository +cd $REPO_ROOT +# use `|| true` so the script still continues even if a pre-commit hook +# applies autofixes (which will result in a nonzero exit code) +pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/tensorflow/tensorflow") || true +# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* +# and we don't need --unsafe-fixes to remove imports +ruff check "$REPO_ROOT/stubs/protobuf" --fix --exit-zero diff --git a/stubs/protobuf/METADATA.toml b/stubs/protobuf/METADATA.toml index ef9831c8a416..e56207d887b4 100644 --- a/stubs/protobuf/METADATA.toml +++ b/stubs/protobuf/METADATA.toml @@ -1,6 +1,6 @@ version = "4.24.*" upstream_repository = "https://github.com/protocolbuffers/protobuf" -extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v23.0](https://github.com/protocolbuffers/protobuf/releases/tag/v23.0) (python protobuf==4.23.0)" +extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v24.4](https://github.com/protocolbuffers/protobuf/releases/tag/v24.4) (python protobuf==4.24.4)" partial_stub = true [tool.stubtest] diff --git a/stubs/protobuf/google/protobuf/any_pb2.pyi b/stubs/protobuf/google/protobuf/any_pb2.pyi index f640918c8a48..011c8628359e 100644 --- a/stubs/protobuf/google/protobuf/any_pb2.pyi +++ b/stubs/protobuf/google/protobuf/any_pb2.pyi @@ -157,7 +157,8 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely used type server + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index 6fe9f85fdab9..bff44a638380 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -71,6 +71,7 @@ class CodeGeneratorRequest(google.protobuf.message.Message): FILE_TO_GENERATE_FIELD_NUMBER: builtins.int PARAMETER_FIELD_NUMBER: builtins.int PROTO_FILE_FIELD_NUMBER: builtins.int + SOURCE_FILE_DESCRIPTORS_FIELD_NUMBER: builtins.int COMPILER_VERSION_FIELD_NUMBER: builtins.int @property def file_to_generate(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: @@ -86,6 +87,11 @@ class CodeGeneratorRequest(google.protobuf.message.Message): they import. The files will appear in topological order, so each file appears before any file that imports it. + Note: the files listed in files_to_generate will include runtime-retention + options only, but all other files will include source-retention options. + The source_file_descriptors field below is available in case you need + source-retention options for files_to_generate. + protoc guarantees that all proto_files will be written after the fields above, even though this is not technically guaranteed by the protobuf wire format. This theoretically could allow a plugin to stream @@ -98,6 +104,12 @@ class CodeGeneratorRequest(google.protobuf.message.Message): fully qualified. """ @property + def source_file_descriptors(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.descriptor_pb2.FileDescriptorProto]: + """File descriptors with all options, including source-retention options. + These descriptors are only provided for the files listed in + files_to_generate. + """ + @property def compiler_version(self) -> global___Version: """The version number of protocol compiler.""" def __init__( @@ -106,10 +118,11 @@ class CodeGeneratorRequest(google.protobuf.message.Message): file_to_generate: collections.abc.Iterable[builtins.str] | None = ..., parameter: builtins.str | None = ..., proto_file: collections.abc.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto] | None = ..., + source_file_descriptors: collections.abc.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto] | None = ..., compiler_version: global___Version | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal["compiler_version", b"compiler_version", "parameter", b"parameter"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["compiler_version", b"compiler_version", "file_to_generate", b"file_to_generate", "parameter", b"parameter", "proto_file", b"proto_file"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["compiler_version", b"compiler_version", "file_to_generate", b"file_to_generate", "parameter", b"parameter", "proto_file", b"proto_file", "source_file_descriptors", b"source_file_descriptors"]) -> None: ... global___CodeGeneratorRequest = CodeGeneratorRequest @@ -127,12 +140,14 @@ class CodeGeneratorResponse(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor FEATURE_NONE: CodeGeneratorResponse._Feature.ValueType # 0 FEATURE_PROTO3_OPTIONAL: CodeGeneratorResponse._Feature.ValueType # 1 + FEATURE_SUPPORTS_EDITIONS: CodeGeneratorResponse._Feature.ValueType # 2 class Feature(_Feature, metaclass=_FeatureEnumTypeWrapper): """Sync with code_generator.h.""" FEATURE_NONE: CodeGeneratorResponse.Feature.ValueType # 0 FEATURE_PROTO3_OPTIONAL: CodeGeneratorResponse.Feature.ValueType # 1 + FEATURE_SUPPORTS_EDITIONS: CodeGeneratorResponse.Feature.ValueType # 2 @typing_extensions.final class File(google.protobuf.message.Message): diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index fc5b450ff2fd..4497bd2f4b31 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -260,7 +260,6 @@ class ExtensionRangeOptions(google.protobuf.message.Message): NUMBER_FIELD_NUMBER: builtins.int FULL_NAME_FIELD_NUMBER: builtins.int TYPE_FIELD_NUMBER: builtins.int - IS_REPEATED_FIELD_NUMBER: builtins.int RESERVED_FIELD_NUMBER: builtins.int REPEATED_FIELD_NUMBER: builtins.int number: builtins.int @@ -274,8 +273,6 @@ class ExtensionRangeOptions(google.protobuf.message.Message): Metadata.type, Declaration.type must have a leading dot for messages and enums. """ - is_repeated: builtins.bool - """Deprecated. Please use "repeated".""" reserved: builtins.bool """If true, indicates that the number is reserved in the extension range, and any extension field with the number will fail to compile. Set this @@ -291,26 +288,28 @@ class ExtensionRangeOptions(google.protobuf.message.Message): number: builtins.int | None = ..., full_name: builtins.str | None = ..., type: builtins.str | None = ..., - is_repeated: builtins.bool | None = ..., reserved: builtins.bool | None = ..., repeated: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "is_repeated", b"is_repeated", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "is_repeated", b"is_repeated", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> None: ... UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int DECLARATION_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int VERIFICATION_FIELD_NUMBER: builtins.int @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" @property def declaration(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ExtensionRangeOptions.Declaration]: - """go/protobuf-stripping-extension-declarations - Like Metadata, but we use a repeated field to hold all extension - declarations. This should avoid the size increases of transforming a large - extension range into small ranges in generated binaries. + """For external users: DO NOT USE. We are in the process of open sourcing + extension declaration and executing internal cleanups before it can be + used externally. """ + @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" verification: global___ExtensionRangeOptions.VerificationState.ValueType """The verification state of the range. TODO(b/278783756): flip the default to DECLARATION once all empty ranges @@ -321,10 +320,11 @@ class ExtensionRangeOptions(google.protobuf.message.Message): *, uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., declaration: collections.abc.Iterable[global___ExtensionRangeOptions.Declaration] | None = ..., + features: global___FeatureSet | None = ..., verification: global___ExtensionRangeOptions.VerificationState.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["verification", b"verification"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["declaration", b"declaration", "uninterpreted_option", b"uninterpreted_option", "verification", b"verification"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["features", b"features", "verification", b"verification"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["declaration", b"declaration", "features", b"features", "uninterpreted_option", b"uninterpreted_option", "verification", b"verification"]) -> None: ... global___ExtensionRangeOptions = ExtensionRangeOptions @@ -783,6 +783,7 @@ class FileOptions(google.protobuf.message.Message): PHP_NAMESPACE_FIELD_NUMBER: builtins.int PHP_METADATA_NAMESPACE_FIELD_NUMBER: builtins.int RUBY_PACKAGE_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int java_package: builtins.str """Sets the Java package where classes generated from this .proto will be @@ -880,6 +881,9 @@ class FileOptions(google.protobuf.message.Message): determining the ruby package. """ @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See the documentation for the "Options" section above. @@ -907,10 +911,11 @@ class FileOptions(google.protobuf.message.Message): php_namespace: builtins.str | None = ..., php_metadata_namespace: builtins.str | None = ..., ruby_package: builtins.str | None = ..., + features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "features", b"features", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "features", b"features", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___FileOptions = FileOptions @@ -923,6 +928,7 @@ class MessageOptions(google.protobuf.message.Message): DEPRECATED_FIELD_NUMBER: builtins.int MAP_ENTRY_FIELD_NUMBER: builtins.int DEPRECATED_LEGACY_JSON_FIELD_CONFLICTS_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int message_set_wire_format: builtins.bool """Set true to use the old proto1 MessageSet wire format for extensions. @@ -991,6 +997,9 @@ class MessageOptions(google.protobuf.message.Message): teams have had time to migrate. """ @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( @@ -1001,10 +1010,11 @@ class MessageOptions(google.protobuf.message.Message): deprecated: builtins.bool | None = ..., map_entry: builtins.bool | None = ..., deprecated_legacy_json_field_conflicts: builtins.bool | None = ..., + features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___MessageOptions = MessageOptions @@ -1119,6 +1129,24 @@ class FieldOptions(google.protobuf.message.Message): TARGET_TYPE_SERVICE: FieldOptions.OptionTargetType.ValueType # 8 TARGET_TYPE_METHOD: FieldOptions.OptionTargetType.ValueType # 9 + @typing_extensions.final + class EditionDefault(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + EDITION_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + edition: builtins.str + value: builtins.str + """Textproto value.""" + def __init__( + self, + *, + edition: builtins.str | None = ..., + value: builtins.str | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "value", b"value"]) -> None: ... + CTYPE_FIELD_NUMBER: builtins.int PACKED_FIELD_NUMBER: builtins.int JSTYPE_FIELD_NUMBER: builtins.int @@ -1128,8 +1156,9 @@ class FieldOptions(google.protobuf.message.Message): WEAK_FIELD_NUMBER: builtins.int DEBUG_REDACT_FIELD_NUMBER: builtins.int RETENTION_FIELD_NUMBER: builtins.int - TARGET_FIELD_NUMBER: builtins.int TARGETS_FIELD_NUMBER: builtins.int + EDITION_DEFAULTS_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int ctype: global___FieldOptions.CType.ValueType """The ctype option instructs the C++ code generator to use a different @@ -1209,10 +1238,14 @@ class FieldOptions(google.protobuf.message.Message): formats, e.g. when the field contains sensitive credentials. """ retention: global___FieldOptions.OptionRetention.ValueType - target: global___FieldOptions.OptionTargetType.ValueType @property def targets(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[global___FieldOptions.OptionTargetType.ValueType]: ... @property + 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.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( @@ -1227,12 +1260,13 @@ class FieldOptions(google.protobuf.message.Message): weak: builtins.bool | None = ..., debug_redact: builtins.bool | None = ..., retention: global___FieldOptions.OptionRetention.ValueType | None = ..., - target: global___FieldOptions.OptionTargetType.ValueType | None = ..., targets: collections.abc.Iterable[global___FieldOptions.OptionTargetType.ValueType] | None = ..., + edition_defaults: collections.abc.Iterable[global___FieldOptions.EditionDefault] | None = ..., + features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "target", b"target", "targets", b"targets", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "edition_defaults", b"edition_defaults", "features", b"features", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "targets", b"targets", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... global___FieldOptions = FieldOptions @@ -1240,16 +1274,22 @@ global___FieldOptions = FieldOptions class OneofOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + FEATURES_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( self, *, + features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___OneofOptions = OneofOptions @@ -1260,6 +1300,7 @@ class EnumOptions(google.protobuf.message.Message): ALLOW_ALIAS_FIELD_NUMBER: builtins.int DEPRECATED_FIELD_NUMBER: builtins.int DEPRECATED_LEGACY_JSON_FIELD_CONFLICTS_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int allow_alias: builtins.bool """Set this option to true to allow mapping different tag names to the same @@ -1280,6 +1321,9 @@ class EnumOptions(google.protobuf.message.Message): had time to migrate. """ @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( @@ -1288,10 +1332,11 @@ class EnumOptions(google.protobuf.message.Message): allow_alias: builtins.bool | None = ..., deprecated: builtins.bool | None = ..., deprecated_legacy_json_field_conflicts: builtins.bool | None = ..., + features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___EnumOptions = EnumOptions @@ -1300,6 +1345,8 @@ class EnumValueOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor DEPRECATED_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int + DEBUG_REDACT_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int deprecated: builtins.bool """Is this enum value deprecated? @@ -1308,16 +1355,26 @@ class EnumValueOptions(google.protobuf.message.Message): this is a formalization for deprecating enum values. """ @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + debug_redact: builtins.bool + """Indicate that fields annotated with this enum value should not be printed + out when using debug formats, e.g. when the field contains sensitive + credentials. + """ + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( self, *, deprecated: builtins.bool | None = ..., + features: global___FeatureSet | None = ..., + debug_redact: builtins.bool | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___EnumValueOptions = EnumValueOptions @@ -1325,8 +1382,12 @@ global___EnumValueOptions = EnumValueOptions class ServiceOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + FEATURES_FIELD_NUMBER: builtins.int DEPRECATED_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int + @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" deprecated: builtins.bool """Note: Field numbers 1 through 32 are reserved for Google's internal RPC framework. We apologize for hoarding these numbers to ourselves, but @@ -1344,11 +1405,12 @@ class ServiceOptions(google.protobuf.message.Message): def __init__( self, *, + features: global___FeatureSet | None = ..., deprecated: builtins.bool | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___ServiceOptions = ServiceOptions @@ -1382,6 +1444,7 @@ class MethodOptions(google.protobuf.message.Message): DEPRECATED_FIELD_NUMBER: builtins.int IDEMPOTENCY_LEVEL_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int deprecated: builtins.bool """Note: Field numbers 1 through 32 are reserved for Google's internal RPC @@ -1396,6 +1459,9 @@ 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.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" def __init__( @@ -1403,10 +1469,11 @@ class MethodOptions(google.protobuf.message.Message): *, deprecated: builtins.bool | None = ..., idempotency_level: global___MethodOptions.IdempotencyLevel.ValueType | None = ..., + features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "idempotency_level", b"idempotency_level"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "idempotency_level", b"idempotency_level", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features", "idempotency_level", b"idempotency_level"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features", "idempotency_level", b"idempotency_level", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___MethodOptions = MethodOptions @@ -1480,6 +1547,146 @@ class UninterpretedOption(google.protobuf.message.Message): global___UninterpretedOption = UninterpretedOption +@typing_extensions.final +class FeatureSet(google.protobuf.message.Message): + """=================================================================== + Features + + TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are + not well scoped. This means that each of the feature enums below can clash + with each other. The short names we've chosen maximize call-site + readability, but leave us very open to this scenario. A future feature will + be designed and implemented to handle this, hopefully before we ever hit a + conflict here. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + class _FieldPresence: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _FieldPresenceEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._FieldPresence.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + FIELD_PRESENCE_UNKNOWN: FeatureSet._FieldPresence.ValueType # 0 + EXPLICIT: FeatureSet._FieldPresence.ValueType # 1 + IMPLICIT: FeatureSet._FieldPresence.ValueType # 2 + LEGACY_REQUIRED: FeatureSet._FieldPresence.ValueType # 3 + + class FieldPresence(_FieldPresence, metaclass=_FieldPresenceEnumTypeWrapper): ... + FIELD_PRESENCE_UNKNOWN: FeatureSet.FieldPresence.ValueType # 0 + EXPLICIT: FeatureSet.FieldPresence.ValueType # 1 + IMPLICIT: FeatureSet.FieldPresence.ValueType # 2 + LEGACY_REQUIRED: FeatureSet.FieldPresence.ValueType # 3 + + class _EnumType: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _EnumTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._EnumType.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + ENUM_TYPE_UNKNOWN: FeatureSet._EnumType.ValueType # 0 + OPEN: FeatureSet._EnumType.ValueType # 1 + CLOSED: FeatureSet._EnumType.ValueType # 2 + + class EnumType(_EnumType, metaclass=_EnumTypeEnumTypeWrapper): ... + ENUM_TYPE_UNKNOWN: FeatureSet.EnumType.ValueType # 0 + OPEN: FeatureSet.EnumType.ValueType # 1 + CLOSED: FeatureSet.EnumType.ValueType # 2 + + class _RepeatedFieldEncoding: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _RepeatedFieldEncodingEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._RepeatedFieldEncoding.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + REPEATED_FIELD_ENCODING_UNKNOWN: FeatureSet._RepeatedFieldEncoding.ValueType # 0 + PACKED: FeatureSet._RepeatedFieldEncoding.ValueType # 1 + EXPANDED: FeatureSet._RepeatedFieldEncoding.ValueType # 2 + + class RepeatedFieldEncoding(_RepeatedFieldEncoding, metaclass=_RepeatedFieldEncodingEnumTypeWrapper): ... + REPEATED_FIELD_ENCODING_UNKNOWN: FeatureSet.RepeatedFieldEncoding.ValueType # 0 + PACKED: FeatureSet.RepeatedFieldEncoding.ValueType # 1 + EXPANDED: FeatureSet.RepeatedFieldEncoding.ValueType # 2 + + class _StringFieldValidation: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _StringFieldValidationEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._StringFieldValidation.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + STRING_FIELD_VALIDATION_UNKNOWN: FeatureSet._StringFieldValidation.ValueType # 0 + MANDATORY: FeatureSet._StringFieldValidation.ValueType # 1 + HINT: FeatureSet._StringFieldValidation.ValueType # 2 + NONE: FeatureSet._StringFieldValidation.ValueType # 3 + + class StringFieldValidation(_StringFieldValidation, metaclass=_StringFieldValidationEnumTypeWrapper): ... + STRING_FIELD_VALIDATION_UNKNOWN: FeatureSet.StringFieldValidation.ValueType # 0 + MANDATORY: FeatureSet.StringFieldValidation.ValueType # 1 + HINT: FeatureSet.StringFieldValidation.ValueType # 2 + NONE: FeatureSet.StringFieldValidation.ValueType # 3 + + class _MessageEncoding: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _MessageEncodingEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._MessageEncoding.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + MESSAGE_ENCODING_UNKNOWN: FeatureSet._MessageEncoding.ValueType # 0 + LENGTH_PREFIXED: FeatureSet._MessageEncoding.ValueType # 1 + DELIMITED: FeatureSet._MessageEncoding.ValueType # 2 + + class MessageEncoding(_MessageEncoding, metaclass=_MessageEncodingEnumTypeWrapper): ... + MESSAGE_ENCODING_UNKNOWN: FeatureSet.MessageEncoding.ValueType # 0 + LENGTH_PREFIXED: FeatureSet.MessageEncoding.ValueType # 1 + DELIMITED: FeatureSet.MessageEncoding.ValueType # 2 + + class _JsonFormat: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + + class _JsonFormatEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._JsonFormat.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + JSON_FORMAT_UNKNOWN: FeatureSet._JsonFormat.ValueType # 0 + ALLOW: FeatureSet._JsonFormat.ValueType # 1 + LEGACY_BEST_EFFORT: FeatureSet._JsonFormat.ValueType # 2 + + class JsonFormat(_JsonFormat, metaclass=_JsonFormatEnumTypeWrapper): ... + JSON_FORMAT_UNKNOWN: FeatureSet.JsonFormat.ValueType # 0 + ALLOW: FeatureSet.JsonFormat.ValueType # 1 + LEGACY_BEST_EFFORT: FeatureSet.JsonFormat.ValueType # 2 + + FIELD_PRESENCE_FIELD_NUMBER: builtins.int + ENUM_TYPE_FIELD_NUMBER: builtins.int + REPEATED_FIELD_ENCODING_FIELD_NUMBER: builtins.int + STRING_FIELD_VALIDATION_FIELD_NUMBER: builtins.int + MESSAGE_ENCODING_FIELD_NUMBER: builtins.int + JSON_FORMAT_FIELD_NUMBER: builtins.int + RAW_FEATURES_FIELD_NUMBER: builtins.int + field_presence: global___FeatureSet.FieldPresence.ValueType + enum_type: global___FeatureSet.EnumType.ValueType + repeated_field_encoding: global___FeatureSet.RepeatedFieldEncoding.ValueType + string_field_validation: global___FeatureSet.StringFieldValidation.ValueType + message_encoding: global___FeatureSet.MessageEncoding.ValueType + json_format: global___FeatureSet.JsonFormat.ValueType + @property + def raw_features(self) -> global___FeatureSet: ... + def __init__( + self, + *, + field_presence: global___FeatureSet.FieldPresence.ValueType | None = ..., + enum_type: global___FeatureSet.EnumType.ValueType | None = ..., + repeated_field_encoding: global___FeatureSet.RepeatedFieldEncoding.ValueType | None = ..., + string_field_validation: global___FeatureSet.StringFieldValidation.ValueType | None = ..., + message_encoding: global___FeatureSet.MessageEncoding.ValueType | None = ..., + json_format: global___FeatureSet.JsonFormat.ValueType | None = ..., + raw_features: global___FeatureSet | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "raw_features", b"raw_features", "repeated_field_encoding", b"repeated_field_encoding", "string_field_validation", b"string_field_validation"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "raw_features", b"raw_features", "repeated_field_encoding", b"repeated_field_encoding", "string_field_validation", b"string_field_validation"]) -> None: ... + +global___FeatureSet = FeatureSet + @typing_extensions.final class SourceCodeInfo(google.protobuf.message.Message): """=================================================================== From c3fb6b8c31479be2e0bb014fea029375a099ff4d Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 Apr 2024 14:20:13 -0400 Subject: [PATCH 04/14] Speedup scripts using uv and filtering to pyi --- scripts/generate_proto_stubs.sh | 9 ++++----- scripts/sync_tensorflow_protobuf_stubs.sh | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 2568e2a8aaac..3b57eda56239 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -41,10 +41,9 @@ unzip "$PYTHON_PROTOBUF_FILENAME" PYTHON_PROTOBUF_DIR="protobuf-$PROTOBUF_VERSION" # Prepare virtualenv -VENV=venv -python3 -m venv "$VENV" -source "$VENV/bin/activate" -pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" +uv venv .venv +source .venv/bin/activate +uv pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" # Remove existing pyi find "$REPO_ROOT/stubs/protobuf/" -name '*_pb2.pyi' -delete @@ -79,7 +78,7 @@ sed --in-place="" \ cd $REPO_ROOT # use `|| true` so the script still continues even if a pre-commit hook # applies autofixes (which will result in a nonzero exit code) -pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf") || true +pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf/**.pyi") || true # Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* # and we don't need --unsafe-fixes to remove imports ruff check "$REPO_ROOT/stubs/protobuf" --fix --exit-zero diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index f0a6324537a5..514a667b4eec 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -15,7 +15,7 @@ TENSORFLOW_VERSION=2.12.1 # protobuf<4. MYPY_PROTOBUF_VERSION=3.5.0 -pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" +uv pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" cd "$(dirname "$0")" > /dev/null cd ../stubs/tensorflow @@ -73,7 +73,7 @@ rm -rf repository/ cd $REPO_ROOT # use `|| true` so the script still continues even if a pre-commit hook # applies autofixes (which will result in a nonzero exit code) -pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/tensorflow/tensorflow") || true +pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/tensorflow/tensorflow/**.pyi") || true # Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* # and we don't need --unsafe-fixes to remove imports -ruff check "$REPO_ROOT/stubs/protobuf" --fix --exit-zero +ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix --exit-zero From bf950d8e6a1ec93736929c1d7d4b7e2b5fa70297 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 Apr 2024 14:49:42 -0400 Subject: [PATCH 05/14] Bump protobuf to v25.3 --- scripts/generate_proto_stubs.sh | 5 +- stubs/protobuf/METADATA.toml | 6 +- .../google/protobuf/descriptor_pb2.pyi | 193 ++++++++++++++---- 3 files changed, 165 insertions(+), 39 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 3b57eda56239..1bbc2e72212e 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -10,8 +10,11 @@ set -ex -o pipefail # a meaningful update to either PROTOBUF_VERSION or MYPY_PROTOBUF_VERSION, # followed by committing the changes to typeshed # +# Whenever you update PROTOBUF_VERSION here, version should be updated +# in stubs/protobuf/METADATA.toml and vice-versa. +# # Update these two variables when rerunning script -PROTOBUF_VERSION=24.4 +PROTOBUF_VERSION=25.3 MYPY_PROTOBUF_VERSION=3.5.0 if uname -a | grep Darwin; then diff --git a/stubs/protobuf/METADATA.toml b/stubs/protobuf/METADATA.toml index e56207d887b4..40c206bd3b0d 100644 --- a/stubs/protobuf/METADATA.toml +++ b/stubs/protobuf/METADATA.toml @@ -1,6 +1,8 @@ -version = "4.24.*" +# Whenever you update version here, PROTOBUF_VERSION should be updated +# in scripts/generate_proto_stubs.sh and vice-versa. +version = "4.25.*" upstream_repository = "https://github.com/protocolbuffers/protobuf" -extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v24.4](https://github.com/protocolbuffers/protobuf/releases/tag/v24.4) (python protobuf==4.24.4)" +extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v25.3](https://github.com/protocolbuffers/protobuf/releases/tag/v25.3) (python protobuf==4.25.3)" partial_stub = true [tool.stubtest] diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index 4497bd2f4b31..f07e6e59c0c9 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -26,6 +26,62 @@ else: DESCRIPTOR: google.protobuf.descriptor.FileDescriptor +class _Edition: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + +class _EditionEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_Edition.ValueType], builtins.type): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + EDITION_UNKNOWN: _Edition.ValueType # 0 + """A placeholder for an unknown edition value.""" + EDITION_PROTO2: _Edition.ValueType # 998 + """Legacy syntax "editions". These pre-date editions, but behave much like + distinct editions. These can't be used to specify the edition of proto + files, but feature definitions must supply proto2/proto3 defaults for + backwards compatibility. + """ + EDITION_PROTO3: _Edition.ValueType # 999 + EDITION_2023: _Edition.ValueType # 1000 + """Editions that have been released. The specific values are arbitrary and + should not be depended on, but they will always be time-ordered for easy + comparison. + """ + EDITION_1_TEST_ONLY: _Edition.ValueType # 1 + """Placeholder editions for testing feature resolution. These should not be + used or relyed on outside of tests. + """ + EDITION_2_TEST_ONLY: _Edition.ValueType # 2 + EDITION_99997_TEST_ONLY: _Edition.ValueType # 99997 + EDITION_99998_TEST_ONLY: _Edition.ValueType # 99998 + EDITION_99999_TEST_ONLY: _Edition.ValueType # 99999 + +class Edition(_Edition, metaclass=_EditionEnumTypeWrapper): + """The full set of known editions.""" + +EDITION_UNKNOWN: Edition.ValueType # 0 +"""A placeholder for an unknown edition value.""" +EDITION_PROTO2: Edition.ValueType # 998 +"""Legacy syntax "editions". These pre-date editions, but behave much like +distinct editions. These can't be used to specify the edition of proto +files, but feature definitions must supply proto2/proto3 defaults for +backwards compatibility. +""" +EDITION_PROTO3: Edition.ValueType # 999 +EDITION_2023: Edition.ValueType # 1000 +"""Editions that have been released. The specific values are arbitrary and +should not be depended on, but they will always be time-ordered for easy +comparison. +""" +EDITION_1_TEST_ONLY: Edition.ValueType # 1 +"""Placeholder editions for testing feature resolution. These should not be +used or relyed on outside of tests. +""" +EDITION_2_TEST_ONLY: Edition.ValueType # 2 +EDITION_99997_TEST_ONLY: Edition.ValueType # 99997 +EDITION_99998_TEST_ONLY: Edition.ValueType # 99998 +EDITION_99999_TEST_ONLY: Edition.ValueType # 99999 +global___Edition = Edition + @typing_extensions.final class FileDescriptorSet(google.protobuf.message.Message): """The protocol compiler can output a FileDescriptorSet containing the .proto @@ -104,8 +160,8 @@ class FileDescriptorProto(google.protobuf.message.Message): If `edition` is present, this value must be "editions". """ - edition: builtins.str - """The edition of the proto file, which is an opaque string.""" + edition: global___Edition.ValueType + """The edition of the proto file.""" def __init__( self, *, @@ -121,7 +177,7 @@ class FileDescriptorProto(google.protobuf.message.Message): options: global___FileOptions | None = ..., source_code_info: global___SourceCodeInfo | None = ..., syntax: builtins.str | None = ..., - edition: builtins.str | None = ..., + edition: global___Edition.ValueType | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "name", b"name", "options", b"options", "package", b"package", "source_code_info", b"source_code_info", "syntax", b"syntax"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal["dependency", b"dependency", "edition", b"edition", "enum_type", b"enum_type", "extension", b"extension", "message_type", b"message_type", "name", b"name", "options", b"options", "package", b"package", "public_dependency", b"public_dependency", "service", b"service", "source_code_info", b"source_code_info", "syntax", b"syntax", "weak_dependency", b"weak_dependency"]) -> None: ... @@ -312,7 +368,7 @@ class ExtensionRangeOptions(google.protobuf.message.Message): """Any features defined in the specific edition.""" verification: global___ExtensionRangeOptions.VerificationState.ValueType """The verification state of the range. - TODO(b/278783756): flip the default to DECLARATION once all empty ranges + TODO: flip the default to DECLARATION once all empty ranges are marked as UNVERIFIED. """ def __init__( @@ -360,9 +416,10 @@ class FieldDescriptorProto(google.protobuf.message.Message): TYPE_STRING: FieldDescriptorProto._Type.ValueType # 9 TYPE_GROUP: FieldDescriptorProto._Type.ValueType # 10 """Tag-delimited aggregate. - Group type is deprecated and not supported in proto3. However, Proto3 + Group type is deprecated and not supported after google.protobuf. However, Proto3 implementations should still be able to parse the group wire format and - treat group fields as unknown fields. + treat group fields as unknown fields. In Editions, the group wire format + can be enabled via the `message_encoding` feature. """ TYPE_MESSAGE: FieldDescriptorProto._Type.ValueType # 11 """Length-delimited aggregate.""" @@ -398,9 +455,10 @@ class FieldDescriptorProto(google.protobuf.message.Message): TYPE_STRING: FieldDescriptorProto.Type.ValueType # 9 TYPE_GROUP: FieldDescriptorProto.Type.ValueType # 10 """Tag-delimited aggregate. - Group type is deprecated and not supported in proto3. However, Proto3 + Group type is deprecated and not supported after google.protobuf. However, Proto3 implementations should still be able to parse the group wire format and - treat group fields as unknown fields. + treat group fields as unknown fields. In Editions, the group wire format + can be enabled via the `message_encoding` feature. """ TYPE_MESSAGE: FieldDescriptorProto.Type.ValueType # 11 """Length-delimited aggregate.""" @@ -423,14 +481,22 @@ class FieldDescriptorProto(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor LABEL_OPTIONAL: FieldDescriptorProto._Label.ValueType # 1 """0 is reserved for errors""" - LABEL_REQUIRED: FieldDescriptorProto._Label.ValueType # 2 LABEL_REPEATED: FieldDescriptorProto._Label.ValueType # 3 + LABEL_REQUIRED: FieldDescriptorProto._Label.ValueType # 2 + """The required label is only allowed in google.protobuf. In proto3 and Editions + it's explicitly prohibited. In Editions, the `field_presence` feature + can be used to get this behavior. + """ class Label(_Label, metaclass=_LabelEnumTypeWrapper): ... LABEL_OPTIONAL: FieldDescriptorProto.Label.ValueType # 1 """0 is reserved for errors""" - LABEL_REQUIRED: FieldDescriptorProto.Label.ValueType # 2 LABEL_REPEATED: FieldDescriptorProto.Label.ValueType # 3 + LABEL_REQUIRED: FieldDescriptorProto.Label.ValueType # 2 + """The required label is only allowed in google.protobuf. In proto3 and Editions + it's explicitly prohibited. In Editions, the `field_presence` feature + can be used to get this behavior. + """ NAME_FIELD_NUMBER: builtins.int NUMBER_FIELD_NUMBER: builtins.int @@ -993,7 +1059,7 @@ class MessageOptions(google.protobuf.message.Message): This should only be used as a temporary measure against broken builds due to the change in behavior for JSON field name conflicts. - TODO(b/261750190) This is legacy behavior we plan to remove once downstream + TODO This is legacy behavior we plan to remove once downstream teams have had time to migrate. """ @property @@ -1135,13 +1201,13 @@ class FieldOptions(google.protobuf.message.Message): EDITION_FIELD_NUMBER: builtins.int VALUE_FIELD_NUMBER: builtins.int - edition: builtins.str + edition: global___Edition.ValueType value: builtins.str """Textproto value.""" def __init__( self, *, - edition: builtins.str | None = ..., + edition: global___Edition.ValueType | None = ..., value: builtins.str | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "value", b"value"]) -> builtins.bool: ... @@ -1173,7 +1239,9 @@ class FieldOptions(google.protobuf.message.Message): a more efficient representation on the wire. Rather than repeatedly writing the tag and type for each element, the entire array is encoded as a single length-delimited blob. In proto3, only explicit setting it to - false will avoid using packed encoding. + false will avoid using packed encoding. This option is prohibited in + Editions, but the `repeated_field_encoding` feature can be used to control + the behavior. """ jstype: global___FieldOptions.JSType.ValueType """The jstype option determines the JavaScript type used for values of the @@ -1317,7 +1385,7 @@ class EnumOptions(google.protobuf.message.Message): and strips underscored from the fields before comparison in proto3 only. The new behavior takes `json_name` into account and applies to proto2 as well. - TODO(b/261750190) Remove this legacy behavior once downstream teams have + TODO Remove this legacy behavior once downstream teams have had time to migrate. """ @property @@ -1552,7 +1620,7 @@ class FeatureSet(google.protobuf.message.Message): """=================================================================== Features - TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are + TODO Enums in C++ gencode (and potentially other languages) are not well scoped. This means that each of the feature enums below can clash with each other. The short names we've chosen maximize call-site readability, but leave us very open to this scenario. A future feature will @@ -1609,22 +1677,20 @@ class FeatureSet(google.protobuf.message.Message): PACKED: FeatureSet.RepeatedFieldEncoding.ValueType # 1 EXPANDED: FeatureSet.RepeatedFieldEncoding.ValueType # 2 - class _StringFieldValidation: + class _Utf8Validation: ValueType = typing.NewType("ValueType", builtins.int) V: typing_extensions.TypeAlias = ValueType - class _StringFieldValidationEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._StringFieldValidation.ValueType], builtins.type): + class _Utf8ValidationEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._Utf8Validation.ValueType], builtins.type): DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor - STRING_FIELD_VALIDATION_UNKNOWN: FeatureSet._StringFieldValidation.ValueType # 0 - MANDATORY: FeatureSet._StringFieldValidation.ValueType # 1 - HINT: FeatureSet._StringFieldValidation.ValueType # 2 - NONE: FeatureSet._StringFieldValidation.ValueType # 3 + UTF8_VALIDATION_UNKNOWN: FeatureSet._Utf8Validation.ValueType # 0 + NONE: FeatureSet._Utf8Validation.ValueType # 1 + VERIFY: FeatureSet._Utf8Validation.ValueType # 2 - class StringFieldValidation(_StringFieldValidation, metaclass=_StringFieldValidationEnumTypeWrapper): ... - STRING_FIELD_VALIDATION_UNKNOWN: FeatureSet.StringFieldValidation.ValueType # 0 - MANDATORY: FeatureSet.StringFieldValidation.ValueType # 1 - HINT: FeatureSet.StringFieldValidation.ValueType # 2 - NONE: FeatureSet.StringFieldValidation.ValueType # 3 + class Utf8Validation(_Utf8Validation, metaclass=_Utf8ValidationEnumTypeWrapper): ... + UTF8_VALIDATION_UNKNOWN: FeatureSet.Utf8Validation.ValueType # 0 + NONE: FeatureSet.Utf8Validation.ValueType # 1 + VERIFY: FeatureSet.Utf8Validation.ValueType # 2 class _MessageEncoding: ValueType = typing.NewType("ValueType", builtins.int) @@ -1659,34 +1725,89 @@ class FeatureSet(google.protobuf.message.Message): FIELD_PRESENCE_FIELD_NUMBER: builtins.int ENUM_TYPE_FIELD_NUMBER: builtins.int REPEATED_FIELD_ENCODING_FIELD_NUMBER: builtins.int - STRING_FIELD_VALIDATION_FIELD_NUMBER: builtins.int + UTF8_VALIDATION_FIELD_NUMBER: builtins.int MESSAGE_ENCODING_FIELD_NUMBER: builtins.int JSON_FORMAT_FIELD_NUMBER: builtins.int - RAW_FEATURES_FIELD_NUMBER: builtins.int field_presence: global___FeatureSet.FieldPresence.ValueType enum_type: global___FeatureSet.EnumType.ValueType repeated_field_encoding: global___FeatureSet.RepeatedFieldEncoding.ValueType - string_field_validation: global___FeatureSet.StringFieldValidation.ValueType + utf8_validation: global___FeatureSet.Utf8Validation.ValueType message_encoding: global___FeatureSet.MessageEncoding.ValueType json_format: global___FeatureSet.JsonFormat.ValueType - @property - def raw_features(self) -> global___FeatureSet: ... def __init__( self, *, field_presence: global___FeatureSet.FieldPresence.ValueType | None = ..., enum_type: global___FeatureSet.EnumType.ValueType | None = ..., repeated_field_encoding: global___FeatureSet.RepeatedFieldEncoding.ValueType | None = ..., - string_field_validation: global___FeatureSet.StringFieldValidation.ValueType | None = ..., + utf8_validation: global___FeatureSet.Utf8Validation.ValueType | None = ..., message_encoding: global___FeatureSet.MessageEncoding.ValueType | None = ..., json_format: global___FeatureSet.JsonFormat.ValueType | None = ..., - raw_features: global___FeatureSet | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "raw_features", b"raw_features", "repeated_field_encoding", b"repeated_field_encoding", "string_field_validation", b"string_field_validation"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["enum_type", b"enum_type", "field_presence", b"field_presence", "json_format", b"json_format", "message_encoding", b"message_encoding", "raw_features", b"raw_features", "repeated_field_encoding", b"repeated_field_encoding", "string_field_validation", b"string_field_validation"]) -> None: ... + def HasField(self, field_name: typing_extensions.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_extensions.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: ... global___FeatureSet = FeatureSet +@typing_extensions.final +class FeatureSetDefaults(google.protobuf.message.Message): + """A compiled specification for the defaults of a set of features. These + messages are generated from FeatureSet extensions and can be used to seed + feature resolution. The resolution with this object becomes a simple search + for the closest matching edition, followed by proto merges. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing_extensions.final + class FeatureSetEditionDefault(google.protobuf.message.Message): + """A map from every known edition with a unique set of defaults to its + defaults. Not all editions may be contained here. For a given edition, + the defaults at the closest matching edition ordered at or before it should + be used. This field must be in strict ascending order by edition. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + EDITION_FIELD_NUMBER: builtins.int + FEATURES_FIELD_NUMBER: builtins.int + edition: global___Edition.ValueType + @property + def features(self) -> global___FeatureSet: ... + def __init__( + self, + *, + edition: global___Edition.ValueType | None = ..., + features: global___FeatureSet | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "features", b"features"]) -> None: ... + + DEFAULTS_FIELD_NUMBER: builtins.int + MINIMUM_EDITION_FIELD_NUMBER: builtins.int + MAXIMUM_EDITION_FIELD_NUMBER: builtins.int + @property + def defaults(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FeatureSetDefaults.FeatureSetEditionDefault]: ... + minimum_edition: global___Edition.ValueType + """The minimum supported edition (inclusive) when this was constructed. + Editions before this will not have defaults. + """ + maximum_edition: global___Edition.ValueType + """The maximum known edition (inclusive) when this was constructed. Editions + after this will not have reliable defaults. + """ + def __init__( + self, + *, + defaults: collections.abc.Iterable[global___FeatureSetDefaults.FeatureSetEditionDefault] | None = ..., + minimum_edition: global___Edition.ValueType | None = ..., + maximum_edition: global___Edition.ValueType | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["defaults", b"defaults", "maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition"]) -> None: ... + +global___FeatureSetDefaults = FeatureSetDefaults + @typing_extensions.final class SourceCodeInfo(google.protobuf.message.Message): """=================================================================== From e3965a73b5542444088199e5eecbe2c5f317d4df Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 8 Apr 2024 12:00:06 -0400 Subject: [PATCH 06/14] reduce changes --- scripts/generate_proto_stubs.sh | 4 ++-- scripts/sync_tensorflow_protobuf_stubs.sh | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 1bbc2e72212e..9bdbcc481fe2 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -44,9 +44,9 @@ unzip "$PYTHON_PROTOBUF_FILENAME" PYTHON_PROTOBUF_DIR="protobuf-$PROTOBUF_VERSION" # Prepare virtualenv -uv venv .venv +python3 -m venv .venv source .venv/bin/activate -uv pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" +python3 -m pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" # Remove existing pyi find "$REPO_ROOT/stubs/protobuf/" -name '*_pb2.pyi' -delete diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 514a667b4eec..29b603c810bd 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -15,7 +15,7 @@ TENSORFLOW_VERSION=2.12.1 # protobuf<4. MYPY_PROTOBUF_VERSION=3.5.0 -uv pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" +pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION" cd "$(dirname "$0")" > /dev/null cd ../stubs/tensorflow @@ -61,6 +61,9 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi +# use `|| true` so the script still continues even if a pre-commit hook +# applies autofixes (which will result in a nonzero exit code) +pre-commit run --files "$REPO_ROOT/stubs/tensorflow/tensorflow" || true sed --in-place="" \ "s/extra_description = .*$/extra_description = \"Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on tensorflow==$TENSORFLOW_VERSION\"/" \ @@ -68,12 +71,3 @@ sed --in-place="" \ # Cleanup last. If the script fails halfway, it's nice to be able to re-run it immediately rm -rf repository/ - -# Must be run in a git repository -cd $REPO_ROOT -# use `|| true` so the script still continues even if a pre-commit hook -# applies autofixes (which will result in a nonzero exit code) -pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/tensorflow/tensorflow/**.pyi") || true -# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* -# and we don't need --unsafe-fixes to remove imports -ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix --exit-zero From ca50b7c4bc784c80e3c86691baf3c11240567a8d Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 8 Apr 2024 12:10:43 -0400 Subject: [PATCH 07/14] Bump mypy-protobuf to v3.6 --- .pre-commit-config.yaml | 7 +- scripts/generate_proto_stubs.sh | 7 +- stubs/protobuf/METADATA.toml | 2 +- stubs/protobuf/google/protobuf/any_pb2.pyi | 7 +- stubs/protobuf/google/protobuf/api_pb2.pyi | 42 ++- .../google/protobuf/compiler/plugin_pb2.pyi | 34 +- .../google/protobuf/descriptor_pb2.pyi | 349 ++++++++++-------- .../protobuf/google/protobuf/duration_pb2.pyi | 7 +- stubs/protobuf/google/protobuf/empty_pb2.pyi | 4 +- .../google/protobuf/field_mask_pb2.pyi | 8 +- .../google/protobuf/source_context_pb2.pyi | 7 +- stubs/protobuf/google/protobuf/struct_pb2.pyi | 27 +- .../google/protobuf/timestamp_pb2.pyi | 7 +- stubs/protobuf/google/protobuf/type_pb2.pyi | 59 +-- .../protobuf/google/protobuf/wrappers_pb2.pyi | 39 +- 15 files changed, 335 insertions(+), 271 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index caab9ddcd620..5b65e0e533b1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,14 +13,15 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.3.5 # must match requirements-tests.txt hooks: - - id: ruff - name: Run ruff on stubs, tests and scripts - args: ["--exit-non-zero-on-fix"] - id: ruff # Run this separately because we don't really want # to use --unsafe-fixes for all rules + # Should be run first as it can leave unused imports behind name: Remove unnecessary `sys.version_info` blocks args: ["--exit-non-zero-on-fix", "--select=UP036", "--unsafe-fixes"] + - id: ruff + name: Run ruff on stubs, tests and scripts + args: ["--exit-non-zero-on-fix"] - id: ruff # Very few rules are useful to run on our test cases; # we explicitly enumerate them here: diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 9bdbcc481fe2..62618adf3de4 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -12,10 +12,8 @@ set -ex -o pipefail # # Whenever you update PROTOBUF_VERSION here, version should be updated # in stubs/protobuf/METADATA.toml and vice-versa. -# -# Update these two variables when rerunning script PROTOBUF_VERSION=25.3 -MYPY_PROTOBUF_VERSION=3.5.0 +MYPY_PROTOBUF_VERSION=3.6.0 if uname -a | grep Darwin; then # brew install coreutils wget @@ -82,6 +80,3 @@ cd $REPO_ROOT # use `|| true` so the script still continues even if a pre-commit hook # applies autofixes (which will result in a nonzero exit code) pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf/**.pyi") || true -# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* -# and we don't need --unsafe-fixes to remove imports -ruff check "$REPO_ROOT/stubs/protobuf" --fix --exit-zero diff --git a/stubs/protobuf/METADATA.toml b/stubs/protobuf/METADATA.toml index 40c206bd3b0d..7585be63c0d2 100644 --- a/stubs/protobuf/METADATA.toml +++ b/stubs/protobuf/METADATA.toml @@ -2,7 +2,7 @@ # in scripts/generate_proto_stubs.sh and vice-versa. version = "4.25.*" upstream_repository = "https://github.com/protocolbuffers/protobuf" -extra_description = "Generated using [mypy-protobuf==3.5.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.5.0) on [protobuf v25.3](https://github.com/protocolbuffers/protobuf/releases/tag/v25.3) (python protobuf==4.25.3)" +extra_description = "Generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) on [protobuf v25.3](https://github.com/protocolbuffers/protobuf/releases/tag/v25.3) (python protobuf==4.25.3)" partial_stub = true [tool.stubtest] diff --git a/stubs/protobuf/google/protobuf/any_pb2.pyi b/stubs/protobuf/google/protobuf/any_pb2.pyi index 011c8628359e..2edfefbfcacd 100644 --- a/stubs/protobuf/google/protobuf/any_pb2.pyi +++ b/stubs/protobuf/google/protobuf/any_pb2.pyi @@ -31,8 +31,9 @@ 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. """ + import builtins -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.internal.well_known_types @@ -40,7 +41,7 @@ import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Any): """`Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. @@ -171,6 +172,6 @@ class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_t type_url: builtins.str | None = ..., value: builtins.bytes | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["type_url", b"type_url", "value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["type_url", b"type_url", "value", b"value"]) -> None: ... global___Any = Any diff --git a/stubs/protobuf/google/protobuf/api_pb2.pyi b/stubs/protobuf/google/protobuf/api_pb2.pyi index 925c1d6c22da..71205bfe4531 100644 --- a/stubs/protobuf/google/protobuf/api_pb2.pyi +++ b/stubs/protobuf/google/protobuf/api_pb2.pyi @@ -31,9 +31,10 @@ 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. """ + import builtins import collections.abc -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.internal.containers @@ -43,7 +44,7 @@ import google.protobuf.type_pb2 DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Api(google.protobuf.message.Message): """Api is a light-weight descriptor for an API Interface. @@ -69,12 +70,6 @@ class Api(google.protobuf.message.Message): """The fully qualified name of this interface, including package name followed by the interface's simple name. """ - @property - def methods(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Method]: - """The methods of this interface, in unspecified order.""" - @property - def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: - """Any metadata attached to the interface.""" version: builtins.str """A version string for this interface. If specified, must have the form `major-version.minor-version`, as in `1.10`. If the minor version is @@ -96,16 +91,26 @@ class Api(google.protobuf.message.Message): be omitted. Zero major versions must only be used for experimental, non-GA interfaces. """ + syntax: google.protobuf.type_pb2.Syntax.ValueType + """The source syntax of the service.""" + @property + def methods(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Method]: + """The methods of this interface, in unspecified order.""" + + @property + def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: + """Any metadata attached to the interface.""" + @property def source_context(self) -> google.protobuf.source_context_pb2.SourceContext: """Source context for the protocol buffer service represented by this message. """ + @property def mixins(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Mixin]: """Included interfaces. See [Mixin][].""" - syntax: google.protobuf.type_pb2.Syntax.ValueType - """The source syntax of the service.""" + def __init__( self, *, @@ -117,12 +122,12 @@ class Api(google.protobuf.message.Message): mixins: collections.abc.Iterable[global___Mixin] | None = ..., syntax: google.protobuf.type_pb2.Syntax.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["source_context", b"source_context"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["methods", b"methods", "mixins", b"mixins", "name", b"name", "options", b"options", "source_context", b"source_context", "syntax", b"syntax", "version", b"version"]) -> None: ... + def HasField(self, field_name: typing.Literal["source_context", b"source_context"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["methods", b"methods", "mixins", b"mixins", "name", b"name", "options", b"options", "source_context", b"source_context", "syntax", b"syntax", "version", b"version"]) -> None: ... global___Api = Api -@typing_extensions.final +@typing.final class Method(google.protobuf.message.Message): """Method represents a method of an API interface.""" @@ -145,11 +150,12 @@ class Method(google.protobuf.message.Message): """The URL of the output message type.""" response_streaming: builtins.bool """If true, the response is streamed.""" + syntax: google.protobuf.type_pb2.Syntax.ValueType + """The source syntax of this method.""" @property def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: """Any metadata attached to the method.""" - syntax: google.protobuf.type_pb2.Syntax.ValueType - """The source syntax of this method.""" + def __init__( self, *, @@ -161,11 +167,11 @@ class Method(google.protobuf.message.Message): options: collections.abc.Iterable[google.protobuf.type_pb2.Option] | None = ..., syntax: google.protobuf.type_pb2.Syntax.ValueType | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options", "request_streaming", b"request_streaming", "request_type_url", b"request_type_url", "response_streaming", b"response_streaming", "response_type_url", b"response_type_url", "syntax", b"syntax"]) -> None: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "options", b"options", "request_streaming", b"request_streaming", "request_type_url", b"request_type_url", "response_streaming", b"response_streaming", "response_type_url", b"response_type_url", "syntax", b"syntax"]) -> None: ... global___Method = Method -@typing_extensions.final +@typing.final class Mixin(google.protobuf.message.Message): """Declares an API Interface to be included in this interface. The including interface must redeclare all the methods from the included interface, but @@ -263,6 +269,6 @@ class Mixin(google.protobuf.message.Message): name: builtins.str | None = ..., root: builtins.str | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "root", b"root"]) -> None: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "root", b"root"]) -> None: ... global___Mixin = Mixin diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index bff44a638380..443cfa2840bd 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -14,6 +14,7 @@ A plugin executable needs only to be placed somewhere in the path. The plugin should be named "protoc-gen-$NAME", and will then be used when the flag "--${NAME}_out" is passed to protoc. """ + import builtins import collections.abc import sys @@ -32,7 +33,7 @@ else: DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Version(google.protobuf.message.Message): """The version number of protocol compiler.""" @@ -57,12 +58,12 @@ class Version(google.protobuf.message.Message): patch: builtins.int | None = ..., suffix: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["major", b"major", "minor", b"minor", "patch", b"patch", "suffix", b"suffix"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["major", b"major", "minor", b"minor", "patch", b"patch", "suffix", b"suffix"]) -> None: ... + def HasField(self, field_name: typing.Literal["major", b"major", "minor", b"minor", "patch", b"patch", "suffix", b"suffix"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["major", b"major", "minor", b"minor", "patch", b"patch", "suffix", b"suffix"]) -> None: ... global___Version = Version -@typing_extensions.final +@typing.final class CodeGeneratorRequest(google.protobuf.message.Message): """An encoded CodeGeneratorRequest is written to the plugin's stdin.""" @@ -73,14 +74,15 @@ class CodeGeneratorRequest(google.protobuf.message.Message): PROTO_FILE_FIELD_NUMBER: builtins.int SOURCE_FILE_DESCRIPTORS_FIELD_NUMBER: builtins.int COMPILER_VERSION_FIELD_NUMBER: builtins.int + parameter: builtins.str + """The generator parameter passed on the command-line.""" @property def file_to_generate(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """The .proto files that were explicitly listed on the command-line. The code generator should generate code only for these files. Each file's descriptor will be included in proto_file, below. """ - parameter: builtins.str - """The generator parameter passed on the command-line.""" + @property def proto_file(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.descriptor_pb2.FileDescriptorProto]: """FileDescriptorProtos for all files in files_to_generate and everything @@ -103,15 +105,18 @@ class CodeGeneratorRequest(google.protobuf.message.Message): Type names of fields and extensions in the FileDescriptorProto are always fully qualified. """ + @property def source_file_descriptors(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.descriptor_pb2.FileDescriptorProto]: """File descriptors with all options, including source-retention options. These descriptors are only provided for the files listed in files_to_generate. """ + @property def compiler_version(self) -> global___Version: """The version number of protocol compiler.""" + def __init__( self, *, @@ -121,12 +126,12 @@ class CodeGeneratorRequest(google.protobuf.message.Message): source_file_descriptors: collections.abc.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto] | None = ..., compiler_version: global___Version | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["compiler_version", b"compiler_version", "parameter", b"parameter"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["compiler_version", b"compiler_version", "file_to_generate", b"file_to_generate", "parameter", b"parameter", "proto_file", b"proto_file", "source_file_descriptors", b"source_file_descriptors"]) -> None: ... + def HasField(self, field_name: typing.Literal["compiler_version", b"compiler_version", "parameter", b"parameter"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["compiler_version", b"compiler_version", "file_to_generate", b"file_to_generate", "parameter", b"parameter", "proto_file", b"proto_file", "source_file_descriptors", b"source_file_descriptors"]) -> None: ... global___CodeGeneratorRequest = CodeGeneratorRequest -@typing_extensions.final +@typing.final class CodeGeneratorResponse(google.protobuf.message.Message): """The plugin writes an encoded CodeGeneratorResponse to stdout.""" @@ -149,7 +154,7 @@ class CodeGeneratorResponse(google.protobuf.message.Message): FEATURE_PROTO3_OPTIONAL: CodeGeneratorResponse.Feature.ValueType # 1 FEATURE_SUPPORTS_EDITIONS: CodeGeneratorResponse.Feature.ValueType # 2 - @typing_extensions.final + @typing.final class File(google.protobuf.message.Message): """Represents a single generated file.""" @@ -219,6 +224,7 @@ class CodeGeneratorResponse(google.protobuf.message.Message): point is used, this information will be appropriately offset and inserted into the code generation metadata for the generated files. """ + def __init__( self, *, @@ -227,8 +233,8 @@ class CodeGeneratorResponse(google.protobuf.message.Message): content: builtins.str | None = ..., generated_code_info: google.protobuf.descriptor_pb2.GeneratedCodeInfo | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["content", b"content", "generated_code_info", b"generated_code_info", "insertion_point", b"insertion_point", "name", b"name"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["content", b"content", "generated_code_info", b"generated_code_info", "insertion_point", b"insertion_point", "name", b"name"]) -> None: ... + def HasField(self, field_name: typing.Literal["content", b"content", "generated_code_info", b"generated_code_info", "insertion_point", b"insertion_point", "name", b"name"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["content", b"content", "generated_code_info", b"generated_code_info", "insertion_point", b"insertion_point", "name", b"name"]) -> None: ... ERROR_FIELD_NUMBER: builtins.int SUPPORTED_FEATURES_FIELD_NUMBER: builtins.int @@ -256,7 +262,7 @@ class CodeGeneratorResponse(google.protobuf.message.Message): supported_features: builtins.int | None = ..., file: collections.abc.Iterable[global___CodeGeneratorResponse.File] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["error", b"error", "supported_features", b"supported_features"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["error", b"error", "file", b"file", "supported_features", b"supported_features"]) -> None: ... + def HasField(self, field_name: typing.Literal["error", b"error", "supported_features", b"supported_features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["error", b"error", "file", b"file", "supported_features", b"supported_features"]) -> None: ... global___CodeGeneratorResponse = CodeGeneratorResponse diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index f07e6e59c0c9..5baf663866af 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -9,6 +9,7 @@ The messages in this file describe the definitions found in .proto files. A valid .proto file can be translated directly to a FileDescriptorProto without any other information (e.g. without reading its imports). """ + import builtins import collections.abc import sys @@ -82,7 +83,7 @@ EDITION_99998_TEST_ONLY: Edition.ValueType # 99998 EDITION_99999_TEST_ONLY: Edition.ValueType # 99999 global___Edition = Edition -@typing_extensions.final +@typing.final class FileDescriptorSet(google.protobuf.message.Message): """The protocol compiler can output a FileDescriptorSet containing the .proto files it parses. @@ -98,11 +99,11 @@ class FileDescriptorSet(google.protobuf.message.Message): *, file: collections.abc.Iterable[global___FileDescriptorProto] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["file", b"file"]) -> None: ... + def ClearField(self, field_name: typing.Literal["file", b"file"]) -> None: ... global___FileDescriptorSet = FileDescriptorSet -@typing_extensions.final +@typing.final class FileDescriptorProto(google.protobuf.message.Message): """Describes a complete .proto file.""" @@ -125,20 +126,32 @@ class FileDescriptorProto(google.protobuf.message.Message): """file name, relative to root of source tree""" package: builtins.str """e.g. "foo", "foo.bar", etc.""" + syntax: builtins.str + """The syntax of the proto file. + The supported values are "proto2", "proto3", and "editions". + + If `edition` is present, this value must be "editions". + """ + edition: global___Edition.ValueType + """The edition of the proto file.""" @property def dependency(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """Names of files imported by this file.""" + @property def public_dependency(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: """Indexes of the public imported files in the dependency list above.""" + @property def weak_dependency(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: """Indexes of the weak imported files in the dependency list. For Google-internal migration only. Do not use. """ + @property def message_type(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___DescriptorProto]: """All top-level definitions in this file.""" + @property def enum_type(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___EnumDescriptorProto]: ... @property @@ -154,14 +167,7 @@ class FileDescriptorProto(google.protobuf.message.Message): functionality of the descriptors -- the information is needed only by development tools. """ - syntax: builtins.str - """The syntax of the proto file. - The supported values are "proto2", "proto3", and "editions". - If `edition` is present, this value must be "editions". - """ - edition: global___Edition.ValueType - """The edition of the proto file.""" def __init__( self, *, @@ -179,18 +185,18 @@ class FileDescriptorProto(google.protobuf.message.Message): syntax: builtins.str | None = ..., edition: global___Edition.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "name", b"name", "options", b"options", "package", b"package", "source_code_info", b"source_code_info", "syntax", b"syntax"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["dependency", b"dependency", "edition", b"edition", "enum_type", b"enum_type", "extension", b"extension", "message_type", b"message_type", "name", b"name", "options", b"options", "package", b"package", "public_dependency", b"public_dependency", "service", b"service", "source_code_info", b"source_code_info", "syntax", b"syntax", "weak_dependency", b"weak_dependency"]) -> None: ... + def HasField(self, field_name: typing.Literal["edition", b"edition", "name", b"name", "options", b"options", "package", b"package", "source_code_info", b"source_code_info", "syntax", b"syntax"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["dependency", b"dependency", "edition", b"edition", "enum_type", b"enum_type", "extension", b"extension", "message_type", b"message_type", "name", b"name", "options", b"options", "package", b"package", "public_dependency", b"public_dependency", "service", b"service", "source_code_info", b"source_code_info", "syntax", b"syntax", "weak_dependency", b"weak_dependency"]) -> None: ... global___FileDescriptorProto = FileDescriptorProto -@typing_extensions.final +@typing.final class DescriptorProto(google.protobuf.message.Message): """Describes a message type.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class ExtensionRange(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -210,10 +216,10 @@ class DescriptorProto(google.protobuf.message.Message): end: builtins.int | None = ..., options: global___ExtensionRangeOptions | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["end", b"end", "options", b"options", "start", b"start"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["end", b"end", "options", b"options", "start", b"start"]) -> None: ... + def HasField(self, field_name: typing.Literal["end", b"end", "options", b"options", "start", b"start"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["end", b"end", "options", b"options", "start", b"start"]) -> None: ... - @typing_extensions.final + @typing.final class ReservedRange(google.protobuf.message.Message): """Range of reserved tag numbers. Reserved tag numbers may not be used by fields or extension ranges in the same message. Reserved ranges may @@ -234,8 +240,8 @@ class DescriptorProto(google.protobuf.message.Message): start: builtins.int | None = ..., end: builtins.int | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["end", b"end", "start", b"start"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["end", b"end", "start", b"start"]) -> None: ... + def HasField(self, field_name: typing.Literal["end", b"end", "start", b"start"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["end", b"end", "start", b"start"]) -> None: ... NAME_FIELD_NUMBER: builtins.int FIELD_FIELD_NUMBER: builtins.int @@ -269,6 +275,7 @@ class DescriptorProto(google.protobuf.message.Message): """Reserved field names, which may not be used by fields in the same message. A given name may only be reserved once. """ + def __init__( self, *, @@ -283,12 +290,12 @@ class DescriptorProto(google.protobuf.message.Message): reserved_range: collections.abc.Iterable[global___DescriptorProto.ReservedRange] | None = ..., reserved_name: collections.abc.Iterable[builtins.str] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["enum_type", b"enum_type", "extension", b"extension", "extension_range", b"extension_range", "field", b"field", "name", b"name", "nested_type", b"nested_type", "oneof_decl", b"oneof_decl", "options", b"options", "reserved_name", b"reserved_name", "reserved_range", b"reserved_range"]) -> None: ... + def HasField(self, field_name: typing.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["enum_type", b"enum_type", "extension", b"extension", "extension_range", b"extension_range", "field", b"field", "name", b"name", "nested_type", b"nested_type", "oneof_decl", b"oneof_decl", "options", b"options", "reserved_name", b"reserved_name", "reserved_range", b"reserved_range"]) -> None: ... global___DescriptorProto = DescriptorProto -@typing_extensions.final +@typing.final class ExtensionRangeOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -309,7 +316,7 @@ class ExtensionRangeOptions(google.protobuf.message.Message): """All the extensions of the range must be declared.""" UNVERIFIED: ExtensionRangeOptions.VerificationState.ValueType # 1 - @typing_extensions.final + @typing.final class Declaration(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -347,30 +354,33 @@ class ExtensionRangeOptions(google.protobuf.message.Message): reserved: builtins.bool | None = ..., repeated: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["full_name", b"full_name", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> None: ... + def HasField(self, field_name: typing.Literal["full_name", b"full_name", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["full_name", b"full_name", "number", b"number", "repeated", b"repeated", "reserved", b"reserved", "type", b"type"]) -> None: ... UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int DECLARATION_FIELD_NUMBER: builtins.int FEATURES_FIELD_NUMBER: builtins.int VERIFICATION_FIELD_NUMBER: builtins.int + verification: global___ExtensionRangeOptions.VerificationState.ValueType + """The verification state of the range. + TODO: flip the default to DECLARATION once all empty ranges + are marked as UNVERIFIED. + """ @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + @property def declaration(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ExtensionRangeOptions.Declaration]: """For external users: DO NOT USE. We are in the process of open sourcing extension declaration and executing internal cleanups before it can be used externally. """ + @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" - verification: global___ExtensionRangeOptions.VerificationState.ValueType - """The verification state of the range. - TODO: flip the default to DECLARATION once all empty ranges - are marked as UNVERIFIED. - """ + def __init__( self, *, @@ -379,12 +389,12 @@ class ExtensionRangeOptions(google.protobuf.message.Message): features: global___FeatureSet | None = ..., verification: global___ExtensionRangeOptions.VerificationState.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["features", b"features", "verification", b"verification"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["declaration", b"declaration", "features", b"features", "uninterpreted_option", b"uninterpreted_option", "verification", b"verification"]) -> None: ... + def HasField(self, field_name: typing.Literal["features", b"features", "verification", b"verification"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["declaration", b"declaration", "features", b"features", "uninterpreted_option", b"uninterpreted_option", "verification", b"verification"]) -> None: ... global___ExtensionRangeOptions = ExtensionRangeOptions -@typing_extensions.final +@typing.final class FieldDescriptorProto(google.protobuf.message.Message): """Describes a field within a message.""" @@ -543,8 +553,6 @@ class FieldDescriptorProto(google.protobuf.message.Message): will be used. Otherwise, it's deduced from the field's name by converting it to camelCase. """ - @property - def options(self) -> global___FieldOptions: ... proto3_optional: builtins.bool """If true, this is a proto3 "optional". When a proto3 field is optional, it tracks presence regardless of field type. @@ -568,6 +576,8 @@ class FieldDescriptorProto(google.protobuf.message.Message): Proto2 optional fields do not set this flag, because they already indicate optional with `LABEL_OPTIONAL`. """ + @property + def options(self) -> global___FieldOptions: ... def __init__( self, *, @@ -583,12 +593,12 @@ class FieldDescriptorProto(google.protobuf.message.Message): options: global___FieldOptions | None = ..., proto3_optional: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["default_value", b"default_value", "extendee", b"extendee", "json_name", b"json_name", "label", b"label", "name", b"name", "number", b"number", "oneof_index", b"oneof_index", "options", b"options", "proto3_optional", b"proto3_optional", "type", b"type", "type_name", b"type_name"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["default_value", b"default_value", "extendee", b"extendee", "json_name", b"json_name", "label", b"label", "name", b"name", "number", b"number", "oneof_index", b"oneof_index", "options", b"options", "proto3_optional", b"proto3_optional", "type", b"type", "type_name", b"type_name"]) -> None: ... + def HasField(self, field_name: typing.Literal["default_value", b"default_value", "extendee", b"extendee", "json_name", b"json_name", "label", b"label", "name", b"name", "number", b"number", "oneof_index", b"oneof_index", "options", b"options", "proto3_optional", b"proto3_optional", "type", b"type", "type_name", b"type_name"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["default_value", b"default_value", "extendee", b"extendee", "json_name", b"json_name", "label", b"label", "name", b"name", "number", b"number", "oneof_index", b"oneof_index", "options", b"options", "proto3_optional", b"proto3_optional", "type", b"type", "type_name", b"type_name"]) -> None: ... global___FieldDescriptorProto = FieldDescriptorProto -@typing_extensions.final +@typing.final class OneofDescriptorProto(google.protobuf.message.Message): """Describes a oneof.""" @@ -605,18 +615,18 @@ class OneofDescriptorProto(google.protobuf.message.Message): name: builtins.str | None = ..., options: global___OneofOptions | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options"]) -> None: ... + def HasField(self, field_name: typing.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "options", b"options"]) -> None: ... global___OneofDescriptorProto = OneofDescriptorProto -@typing_extensions.final +@typing.final class EnumDescriptorProto(google.protobuf.message.Message): """Describes an enum type.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class EnumReservedRange(google.protobuf.message.Message): """Range of reserved numeric values. Reserved values may not be used by entries in the same enum. Reserved ranges may not overlap. @@ -640,8 +650,8 @@ class EnumDescriptorProto(google.protobuf.message.Message): start: builtins.int | None = ..., end: builtins.int | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["end", b"end", "start", b"start"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["end", b"end", "start", b"start"]) -> None: ... + def HasField(self, field_name: typing.Literal["end", b"end", "start", b"start"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["end", b"end", "start", b"start"]) -> None: ... NAME_FIELD_NUMBER: builtins.int VALUE_FIELD_NUMBER: builtins.int @@ -659,11 +669,13 @@ class EnumDescriptorProto(google.protobuf.message.Message): by enum values in the same enum declaration. Reserved ranges may not overlap. """ + @property def reserved_name(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """Reserved enum value names, which may not be reused. A given name may only be reserved once. """ + def __init__( self, *, @@ -673,12 +685,12 @@ class EnumDescriptorProto(google.protobuf.message.Message): reserved_range: collections.abc.Iterable[global___EnumDescriptorProto.EnumReservedRange] | None = ..., reserved_name: collections.abc.Iterable[builtins.str] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options", "reserved_name", b"reserved_name", "reserved_range", b"reserved_range", "value", b"value"]) -> None: ... + def HasField(self, field_name: typing.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "options", b"options", "reserved_name", b"reserved_name", "reserved_range", b"reserved_range", "value", b"value"]) -> None: ... global___EnumDescriptorProto = EnumDescriptorProto -@typing_extensions.final +@typing.final class EnumValueDescriptorProto(google.protobuf.message.Message): """Describes a value within an enum.""" @@ -698,12 +710,12 @@ class EnumValueDescriptorProto(google.protobuf.message.Message): number: builtins.int | None = ..., options: global___EnumValueOptions | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["name", b"name", "number", b"number", "options", b"options"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "number", b"number", "options", b"options"]) -> None: ... + def HasField(self, field_name: typing.Literal["name", b"name", "number", b"number", "options", b"options"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "number", b"number", "options", b"options"]) -> None: ... global___EnumValueDescriptorProto = EnumValueDescriptorProto -@typing_extensions.final +@typing.final class ServiceDescriptorProto(google.protobuf.message.Message): """Describes a service.""" @@ -724,12 +736,12 @@ class ServiceDescriptorProto(google.protobuf.message.Message): method: collections.abc.Iterable[global___MethodDescriptorProto] | None = ..., options: global___ServiceOptions | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["method", b"method", "name", b"name", "options", b"options"]) -> None: ... + def HasField(self, field_name: typing.Literal["name", b"name", "options", b"options"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["method", b"method", "name", b"name", "options", b"options"]) -> None: ... global___ServiceDescriptorProto = ServiceDescriptorProto -@typing_extensions.final +@typing.final class MethodDescriptorProto(google.protobuf.message.Message): """Describes a method of a service.""" @@ -747,12 +759,12 @@ class MethodDescriptorProto(google.protobuf.message.Message): FieldDescriptorProto.type_name, but must refer to a message type. """ output_type: builtins.str - @property - def options(self) -> global___MethodOptions: ... client_streaming: builtins.bool """Identifies if client streams multiple client messages""" server_streaming: builtins.bool """Identifies if server streams multiple server messages""" + @property + def options(self) -> global___MethodOptions: ... def __init__( self, *, @@ -763,12 +775,12 @@ class MethodDescriptorProto(google.protobuf.message.Message): client_streaming: builtins.bool | None = ..., server_streaming: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["client_streaming", b"client_streaming", "input_type", b"input_type", "name", b"name", "options", b"options", "output_type", b"output_type", "server_streaming", b"server_streaming"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["client_streaming", b"client_streaming", "input_type", b"input_type", "name", b"name", "options", b"options", "output_type", b"output_type", "server_streaming", b"server_streaming"]) -> None: ... + def HasField(self, field_name: typing.Literal["client_streaming", b"client_streaming", "input_type", b"input_type", "name", b"name", "options", b"options", "output_type", b"output_type", "server_streaming", b"server_streaming"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["client_streaming", b"client_streaming", "input_type", b"input_type", "name", b"name", "options", b"options", "output_type", b"output_type", "server_streaming", b"server_streaming"]) -> None: ... global___MethodDescriptorProto = MethodDescriptorProto -@typing_extensions.final +@typing.final class FileOptions(google.protobuf.message.Message): """Each of the definitions above may have "options" attached. These are just annotations which may cause code to be generated slightly differently @@ -949,11 +961,13 @@ class FileOptions(google.protobuf.message.Message): @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See the documentation for the "Options" section above. """ + def __init__( self, *, @@ -980,12 +994,12 @@ class FileOptions(google.protobuf.message.Message): features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "features", b"features", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "features", b"features", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "features", b"features", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["cc_enable_arenas", b"cc_enable_arenas", "cc_generic_services", b"cc_generic_services", "csharp_namespace", b"csharp_namespace", "deprecated", b"deprecated", "features", b"features", "go_package", b"go_package", "java_generate_equals_and_hash", b"java_generate_equals_and_hash", "java_generic_services", b"java_generic_services", "java_multiple_files", b"java_multiple_files", "java_outer_classname", b"java_outer_classname", "java_package", b"java_package", "java_string_check_utf8", b"java_string_check_utf8", "objc_class_prefix", b"objc_class_prefix", "optimize_for", b"optimize_for", "php_class_prefix", b"php_class_prefix", "php_generic_services", b"php_generic_services", "php_metadata_namespace", b"php_metadata_namespace", "php_namespace", b"php_namespace", "py_generic_services", b"py_generic_services", "ruby_package", b"ruby_package", "swift_prefix", b"swift_prefix", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___FileOptions = FileOptions -@typing_extensions.final +@typing.final class MessageOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1065,9 +1079,11 @@ class MessageOptions(google.protobuf.message.Message): @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, @@ -1079,12 +1095,12 @@ class MessageOptions(google.protobuf.message.Message): features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "map_entry", b"map_entry", "message_set_wire_format", b"message_set_wire_format", "no_standard_descriptor_accessor", b"no_standard_descriptor_accessor", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___MessageOptions = MessageOptions -@typing_extensions.final +@typing.final class FieldOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1195,7 +1211,7 @@ class FieldOptions(google.protobuf.message.Message): TARGET_TYPE_SERVICE: FieldOptions.OptionTargetType.ValueType # 8 TARGET_TYPE_METHOD: FieldOptions.OptionTargetType.ValueType # 9 - @typing_extensions.final + @typing.final class EditionDefault(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1210,8 +1226,8 @@ class FieldOptions(google.protobuf.message.Message): edition: global___Edition.ValueType | None = ..., value: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "value", b"value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "value", b"value"]) -> None: ... + def HasField(self, field_name: typing.Literal["edition", b"edition", "value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["edition", b"edition", "value", b"value"]) -> None: ... CTYPE_FIELD_NUMBER: builtins.int PACKED_FIELD_NUMBER: builtins.int @@ -1313,9 +1329,11 @@ class FieldOptions(google.protobuf.message.Message): @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, @@ -1333,12 +1351,12 @@ class FieldOptions(google.protobuf.message.Message): features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "edition_defaults", b"edition_defaults", "features", b"features", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "targets", b"targets", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... + def HasField(self, field_name: typing.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["ctype", b"ctype", "debug_redact", b"debug_redact", "deprecated", b"deprecated", "edition_defaults", b"edition_defaults", "features", b"features", "jstype", b"jstype", "lazy", b"lazy", "packed", b"packed", "retention", b"retention", "targets", b"targets", "uninterpreted_option", b"uninterpreted_option", "unverified_lazy", b"unverified_lazy", "weak", b"weak"]) -> None: ... global___FieldOptions = FieldOptions -@typing_extensions.final +@typing.final class OneofOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1347,21 +1365,23 @@ class OneofOptions(google.protobuf.message.Message): @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["features", b"features"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___OneofOptions = OneofOptions -@typing_extensions.final +@typing.final class EnumOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1391,9 +1411,11 @@ class EnumOptions(google.protobuf.message.Message): @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, @@ -1403,12 +1425,12 @@ class EnumOptions(google.protobuf.message.Message): features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["allow_alias", b"allow_alias", "deprecated", b"deprecated", "deprecated_legacy_json_field_conflicts", b"deprecated_legacy_json_field_conflicts", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___EnumOptions = EnumOptions -@typing_extensions.final +@typing.final class EnumValueOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1422,17 +1444,19 @@ class EnumValueOptions(google.protobuf.message.Message): for the enum value, or it will be completely ignored; in the very least, this is a formalization for deprecating enum values. """ - @property - def features(self) -> global___FeatureSet: - """Any features defined in the specific edition.""" debug_redact: builtins.bool """Indicate that fields annotated with this enum value should not be printed out when using debug formats, e.g. when the field contains sensitive credentials. """ + @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, @@ -1441,21 +1465,18 @@ class EnumValueOptions(google.protobuf.message.Message): debug_redact: builtins.bool | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["debug_redact", b"debug_redact", "deprecated", b"deprecated", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___EnumValueOptions = EnumValueOptions -@typing_extensions.final +@typing.final class ServiceOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor FEATURES_FIELD_NUMBER: builtins.int DEPRECATED_FIELD_NUMBER: builtins.int UNINTERPRETED_OPTION_FIELD_NUMBER: builtins.int - @property - def features(self) -> global___FeatureSet: - """Any features defined in the specific edition.""" deprecated: builtins.bool """Note: Field numbers 1 through 32 are reserved for Google's internal RPC framework. We apologize for hoarding these numbers to ourselves, but @@ -1467,9 +1488,14 @@ class ServiceOptions(google.protobuf.message.Message): for the service, or it will be completely ignored; in the very least, this is a formalization for deprecating services. """ + @property + def features(self) -> global___FeatureSet: + """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, @@ -1477,12 +1503,12 @@ class ServiceOptions(google.protobuf.message.Message): deprecated: builtins.bool | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["deprecated", b"deprecated", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["deprecated", b"deprecated", "features", b"features", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___ServiceOptions = ServiceOptions -@typing_extensions.final +@typing.final class MethodOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1529,9 +1555,11 @@ class MethodOptions(google.protobuf.message.Message): @property def features(self) -> global___FeatureSet: """Any features defined in the specific edition.""" + @property def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: """The parser stores options it doesn't recognize here. See above.""" + def __init__( self, *, @@ -1540,12 +1568,12 @@ class MethodOptions(google.protobuf.message.Message): features: global___FeatureSet | None = ..., uninterpreted_option: collections.abc.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features", "idempotency_level", b"idempotency_level"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["deprecated", b"deprecated", "features", b"features", "idempotency_level", b"idempotency_level", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... + def HasField(self, field_name: typing.Literal["deprecated", b"deprecated", "features", b"features", "idempotency_level", b"idempotency_level"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["deprecated", b"deprecated", "features", b"features", "idempotency_level", b"idempotency_level", "uninterpreted_option", b"uninterpreted_option"]) -> None: ... global___MethodOptions = MethodOptions -@typing_extensions.final +@typing.final class UninterpretedOption(google.protobuf.message.Message): """A message representing a option the parser does not recognize. This only appears in options protos created by the compiler::Parser class. @@ -1557,7 +1585,7 @@ class UninterpretedOption(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class NamePart(google.protobuf.message.Message): """The name of the uninterpreted option. Each string represents a segment in a dot-separated name. is_extension is true iff a segment represents an @@ -1578,8 +1606,8 @@ class UninterpretedOption(google.protobuf.message.Message): name_part: builtins.str | None = ..., is_extension: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["is_extension", b"is_extension", "name_part", b"name_part"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["is_extension", b"is_extension", "name_part", b"name_part"]) -> None: ... + def HasField(self, field_name: typing.Literal["is_extension", b"is_extension", "name_part", b"name_part"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["is_extension", b"is_extension", "name_part", b"name_part"]) -> None: ... NAME_FIELD_NUMBER: builtins.int IDENTIFIER_VALUE_FIELD_NUMBER: builtins.int @@ -1588,8 +1616,6 @@ class UninterpretedOption(google.protobuf.message.Message): DOUBLE_VALUE_FIELD_NUMBER: builtins.int STRING_VALUE_FIELD_NUMBER: builtins.int AGGREGATE_VALUE_FIELD_NUMBER: builtins.int - @property - def name(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption.NamePart]: ... identifier_value: builtins.str """The value of the uninterpreted option, in whatever type the tokenizer identified it as during parsing. Exactly one of these should be set. @@ -1599,6 +1625,8 @@ class UninterpretedOption(google.protobuf.message.Message): double_value: builtins.float string_value: builtins.bytes aggregate_value: builtins.str + @property + def name(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption.NamePart]: ... def __init__( self, *, @@ -1610,12 +1638,12 @@ class UninterpretedOption(google.protobuf.message.Message): string_value: builtins.bytes | None = ..., aggregate_value: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["aggregate_value", b"aggregate_value", "double_value", b"double_value", "identifier_value", b"identifier_value", "negative_int_value", b"negative_int_value", "positive_int_value", b"positive_int_value", "string_value", b"string_value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["aggregate_value", b"aggregate_value", "double_value", b"double_value", "identifier_value", b"identifier_value", "name", b"name", "negative_int_value", b"negative_int_value", "positive_int_value", b"positive_int_value", "string_value", b"string_value"]) -> None: ... + def HasField(self, field_name: typing.Literal["aggregate_value", b"aggregate_value", "double_value", b"double_value", "identifier_value", b"identifier_value", "negative_int_value", b"negative_int_value", "positive_int_value", b"positive_int_value", "string_value", b"string_value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["aggregate_value", b"aggregate_value", "double_value", b"double_value", "identifier_value", b"identifier_value", "name", b"name", "negative_int_value", b"negative_int_value", "positive_int_value", b"positive_int_value", "string_value", b"string_value"]) -> None: ... global___UninterpretedOption = UninterpretedOption -@typing_extensions.final +@typing.final class FeatureSet(google.protobuf.message.Message): """=================================================================== Features @@ -1744,12 +1772,12 @@ class FeatureSet(google.protobuf.message.Message): message_encoding: global___FeatureSet.MessageEncoding.ValueType | None = ..., json_format: global___FeatureSet.JsonFormat.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.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_extensions.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["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: ... global___FeatureSet = FeatureSet -@typing_extensions.final +@typing.final class FeatureSetDefaults(google.protobuf.message.Message): """A compiled specification for the defaults of a set of features. These messages are generated from FeatureSet extensions and can be used to seed @@ -1759,7 +1787,7 @@ class FeatureSetDefaults(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class FeatureSetEditionDefault(google.protobuf.message.Message): """A map from every known edition with a unique set of defaults to its defaults. Not all editions may be contained here. For a given edition, @@ -1780,14 +1808,12 @@ class FeatureSetDefaults(google.protobuf.message.Message): edition: global___Edition.ValueType | None = ..., features: global___FeatureSet | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["edition", b"edition", "features", b"features"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "features", b"features"]) -> None: ... + def HasField(self, field_name: typing.Literal["edition", b"edition", "features", b"features"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["edition", b"edition", "features", b"features"]) -> None: ... DEFAULTS_FIELD_NUMBER: builtins.int MINIMUM_EDITION_FIELD_NUMBER: builtins.int MAXIMUM_EDITION_FIELD_NUMBER: builtins.int - @property - def defaults(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FeatureSetDefaults.FeatureSetEditionDefault]: ... minimum_edition: global___Edition.ValueType """The minimum supported edition (inclusive) when this was constructed. Editions before this will not have defaults. @@ -1796,6 +1822,8 @@ class FeatureSetDefaults(google.protobuf.message.Message): """The maximum known edition (inclusive) when this was constructed. Editions after this will not have reliable defaults. """ + @property + def defaults(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FeatureSetDefaults.FeatureSetEditionDefault]: ... def __init__( self, *, @@ -1803,12 +1831,12 @@ class FeatureSetDefaults(google.protobuf.message.Message): minimum_edition: global___Edition.ValueType | None = ..., maximum_edition: global___Edition.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["defaults", b"defaults", "maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition"]) -> None: ... + def HasField(self, field_name: typing.Literal["maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["defaults", b"defaults", "maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition"]) -> None: ... global___FeatureSetDefaults = FeatureSetDefaults -@typing_extensions.final +@typing.final class SourceCodeInfo(google.protobuf.message.Message): """=================================================================== Optional source code info @@ -1819,7 +1847,7 @@ class SourceCodeInfo(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class Location(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1828,40 +1856,6 @@ class SourceCodeInfo(google.protobuf.message.Message): LEADING_COMMENTS_FIELD_NUMBER: builtins.int TRAILING_COMMENTS_FIELD_NUMBER: builtins.int LEADING_DETACHED_COMMENTS_FIELD_NUMBER: builtins.int - @property - def path(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: - """Identifies which part of the FileDescriptorProto was defined at this - location. - - Each element is a field number or an index. They form a path from - the root FileDescriptorProto to the place where the definition occurs. - For example, this path: - [ 4, 3, 2, 7, 1 ] - refers to: - file.message_type(3) // 4, 3 - .field(7) // 2, 7 - .name() // 1 - This is because FileDescriptorProto.message_type has field number 4: - repeated DescriptorProto message_type = 4; - and DescriptorProto.field has field number 2: - repeated FieldDescriptorProto field = 2; - and FieldDescriptorProto.name has field number 1: - optional string name = 1; - - Thus, the above path gives the location of a field name. If we removed - the last element: - [ 4, 3, 2, 7 ] - this path refers to the whole field declaration (from the beginning - of the label to the terminating semicolon). - """ - @property - def span(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: - """Always has exactly three or four elements: start line, start column, - end line (optional, otherwise assumed same as start line), end column. - These are packed into a single field for efficiency. Note that line - and column numbers are zero-based -- typically you will want to add - 1 to each before displaying to a user. - """ leading_comments: builtins.str """If this SourceCodeInfo represents a complete declaration, these are any comments appearing before and after the declaration which appear to be @@ -1912,6 +1906,42 @@ class SourceCodeInfo(google.protobuf.message.Message): // ignored detached comments. """ trailing_comments: builtins.str + @property + def path(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: + """Identifies which part of the FileDescriptorProto was defined at this + location. + + Each element is a field number or an index. They form a path from + the root FileDescriptorProto to the place where the definition occurs. + For example, this path: + [ 4, 3, 2, 7, 1 ] + refers to: + file.message_type(3) // 4, 3 + .field(7) // 2, 7 + .name() // 1 + This is because FileDescriptorProto.message_type has field number 4: + repeated DescriptorProto message_type = 4; + and DescriptorProto.field has field number 2: + repeated FieldDescriptorProto field = 2; + and FieldDescriptorProto.name has field number 1: + optional string name = 1; + + Thus, the above path gives the location of a field name. If we removed + the last element: + [ 4, 3, 2, 7 ] + this path refers to the whole field declaration (from the beginning + of the label to the terminating semicolon). + """ + + @property + def span(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: + """Always has exactly three or four elements: start line, start column, + end line (optional, otherwise assumed same as start line), end column. + These are packed into a single field for efficiency. Note that line + and column numbers are zero-based -- typically you will want to add + 1 to each before displaying to a user. + """ + @property def leading_detached_comments(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... def __init__( @@ -1923,8 +1953,8 @@ class SourceCodeInfo(google.protobuf.message.Message): trailing_comments: builtins.str | None = ..., leading_detached_comments: collections.abc.Iterable[builtins.str] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["leading_comments", b"leading_comments", "trailing_comments", b"trailing_comments"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["leading_comments", b"leading_comments", "leading_detached_comments", b"leading_detached_comments", "path", b"path", "span", b"span", "trailing_comments", b"trailing_comments"]) -> None: ... + def HasField(self, field_name: typing.Literal["leading_comments", b"leading_comments", "trailing_comments", b"trailing_comments"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["leading_comments", b"leading_comments", "leading_detached_comments", b"leading_detached_comments", "path", b"path", "span", b"span", "trailing_comments", b"trailing_comments"]) -> None: ... LOCATION_FIELD_NUMBER: builtins.int @property @@ -1973,16 +2003,17 @@ class SourceCodeInfo(google.protobuf.message.Message): ignore those that it doesn't understand, as more types of locations could be recorded in the future. """ + def __init__( self, *, location: collections.abc.Iterable[global___SourceCodeInfo.Location] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["location", b"location"]) -> None: ... + def ClearField(self, field_name: typing.Literal["location", b"location"]) -> None: ... global___SourceCodeInfo = SourceCodeInfo -@typing_extensions.final +@typing.final class GeneratedCodeInfo(google.protobuf.message.Message): """Describes the relationship between generated code and its original source file. A GeneratedCodeInfo message is associated with only one generated @@ -1991,7 +2022,7 @@ class GeneratedCodeInfo(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class Annotation(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -2025,11 +2056,6 @@ class GeneratedCodeInfo(google.protobuf.message.Message): BEGIN_FIELD_NUMBER: builtins.int END_FIELD_NUMBER: builtins.int SEMANTIC_FIELD_NUMBER: builtins.int - @property - def path(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: - """Identifies the element in the original source .proto file. This field - is formatted the same as SourceCodeInfo.Location.path. - """ source_file: builtins.str """Identifies the filesystem path to the original source .proto.""" begin: builtins.int @@ -2042,6 +2068,12 @@ class GeneratedCodeInfo(google.protobuf.message.Message): the last relevant byte (so the length of the text = end - begin). """ semantic: global___GeneratedCodeInfo.Annotation.Semantic.ValueType + @property + def path(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: + """Identifies the element in the original source .proto file. This field + is formatted the same as SourceCodeInfo.Location.path. + """ + def __init__( self, *, @@ -2051,8 +2083,8 @@ class GeneratedCodeInfo(google.protobuf.message.Message): end: builtins.int | None = ..., semantic: global___GeneratedCodeInfo.Annotation.Semantic.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["begin", b"begin", "end", b"end", "semantic", b"semantic", "source_file", b"source_file"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["begin", b"begin", "end", b"end", "path", b"path", "semantic", b"semantic", "source_file", b"source_file"]) -> None: ... + def HasField(self, field_name: typing.Literal["begin", b"begin", "end", b"end", "semantic", b"semantic", "source_file", b"source_file"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["begin", b"begin", "end", b"end", "path", b"path", "semantic", b"semantic", "source_file", b"source_file"]) -> None: ... ANNOTATION_FIELD_NUMBER: builtins.int @property @@ -2060,11 +2092,12 @@ class GeneratedCodeInfo(google.protobuf.message.Message): """An Annotation connects some span of text in generated code to an element of its generating .proto file. """ + def __init__( self, *, annotation: collections.abc.Iterable[global___GeneratedCodeInfo.Annotation] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["annotation", b"annotation"]) -> None: ... + def ClearField(self, field_name: typing.Literal["annotation", b"annotation"]) -> None: ... global___GeneratedCodeInfo = GeneratedCodeInfo diff --git a/stubs/protobuf/google/protobuf/duration_pb2.pyi b/stubs/protobuf/google/protobuf/duration_pb2.pyi index a97b8d9251a8..4beb927266cb 100644 --- a/stubs/protobuf/google/protobuf/duration_pb2.pyi +++ b/stubs/protobuf/google/protobuf/duration_pb2.pyi @@ -31,8 +31,9 @@ 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. """ + import builtins -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.internal.well_known_types @@ -40,7 +41,7 @@ import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Duration(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Duration): """A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond @@ -125,6 +126,6 @@ class Duration(google.protobuf.message.Message, google.protobuf.internal.well_kn seconds: builtins.int | None = ..., nanos: builtins.int | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... + def ClearField(self, field_name: typing.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... global___Duration = Duration diff --git a/stubs/protobuf/google/protobuf/empty_pb2.pyi b/stubs/protobuf/google/protobuf/empty_pb2.pyi index f0f42ceb20f2..593917f63474 100644 --- a/stubs/protobuf/google/protobuf/empty_pb2.pyi +++ b/stubs/protobuf/google/protobuf/empty_pb2.pyi @@ -32,14 +32,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Empty(google.protobuf.message.Message): """A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request diff --git a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi index 60d15e8765b0..1cc4929f00b5 100644 --- a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi +++ b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi @@ -31,9 +31,10 @@ 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. """ + import builtins import collections.abc -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.internal.containers @@ -42,7 +43,7 @@ import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class FieldMask(google.protobuf.message.Message, google.protobuf.internal.well_known_types.FieldMask): """`FieldMask` represents a set of symbolic field paths, for example: @@ -251,11 +252,12 @@ class FieldMask(google.protobuf.message.Message, google.protobuf.internal.well_k @property def paths(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """The set of field mask paths.""" + def __init__( self, *, paths: collections.abc.Iterable[builtins.str] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["paths", b"paths"]) -> None: ... + def ClearField(self, field_name: typing.Literal["paths", b"paths"]) -> None: ... global___FieldMask = FieldMask diff --git a/stubs/protobuf/google/protobuf/source_context_pb2.pyi b/stubs/protobuf/google/protobuf/source_context_pb2.pyi index b93ab58d0251..a2d35937211d 100644 --- a/stubs/protobuf/google/protobuf/source_context_pb2.pyi +++ b/stubs/protobuf/google/protobuf/source_context_pb2.pyi @@ -31,15 +31,16 @@ 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. """ + import builtins -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class SourceContext(google.protobuf.message.Message): """`SourceContext` represents information about the source of a protobuf element, like the file in which it is defined. @@ -57,6 +58,6 @@ class SourceContext(google.protobuf.message.Message): *, file_name: builtins.str | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["file_name", b"file_name"]) -> None: ... + def ClearField(self, field_name: typing.Literal["file_name", b"file_name"]) -> None: ... global___SourceContext = SourceContext diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index 8b80de0c4b65..684f3c9d4e08 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -31,6 +31,7 @@ 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. """ + import builtins import collections.abc import sys @@ -69,7 +70,7 @@ NULL_VALUE: NullValue.ValueType # 0 """Null value.""" global___NullValue = NullValue -@typing_extensions.final +@typing.final class Struct(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Struct): """`Struct` represents a structured data value, consisting of fields which map to dynamically typed values. In some languages, `Struct` @@ -83,7 +84,7 @@ class Struct(google.protobuf.message.Message, google.protobuf.internal.well_know DESCRIPTOR: google.protobuf.descriptor.Descriptor - @typing_extensions.final + @typing.final class FieldsEntry(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -98,23 +99,24 @@ class Struct(google.protobuf.message.Message, google.protobuf.internal.well_know key: builtins.str | None = ..., value: global___Value | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["value", b"value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... FIELDS_FIELD_NUMBER: builtins.int @property def fields(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___Value]: """Unordered map of dynamically typed values.""" + def __init__( self, *, fields: collections.abc.Mapping[builtins.str, global___Value] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["fields", b"fields"]) -> None: ... + def ClearField(self, field_name: typing.Literal["fields", b"fields"]) -> None: ... global___Struct = Struct -@typing_extensions.final +@typing.final class Value(google.protobuf.message.Message): """`Value` represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a @@ -143,9 +145,11 @@ class Value(google.protobuf.message.Message): @property def struct_value(self) -> global___Struct: """Represents a structured value.""" + @property def list_value(self) -> global___ListValue: """Represents a repeated `Value`.""" + def __init__( self, *, @@ -156,13 +160,13 @@ class Value(google.protobuf.message.Message): struct_value: global___Struct | None = ..., list_value: global___ListValue | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["bool_value", b"bool_value", "kind", b"kind", "list_value", b"list_value", "null_value", b"null_value", "number_value", b"number_value", "string_value", b"string_value", "struct_value", b"struct_value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["bool_value", b"bool_value", "kind", b"kind", "list_value", b"list_value", "null_value", b"null_value", "number_value", b"number_value", "string_value", b"string_value", "struct_value", b"struct_value"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal["kind", b"kind"]) -> typing_extensions.Literal["null_value", "number_value", "string_value", "bool_value", "struct_value", "list_value"] | None: ... + def HasField(self, field_name: typing.Literal["bool_value", b"bool_value", "kind", b"kind", "list_value", b"list_value", "null_value", b"null_value", "number_value", b"number_value", "string_value", b"string_value", "struct_value", b"struct_value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["bool_value", b"bool_value", "kind", b"kind", "list_value", b"list_value", "null_value", b"null_value", "number_value", b"number_value", "string_value", b"string_value", "struct_value", b"struct_value"]) -> None: ... + def WhichOneof(self, oneof_group: typing.Literal["kind", b"kind"]) -> typing.Literal["null_value", "number_value", "string_value", "bool_value", "struct_value", "list_value"] | None: ... global___Value = Value -@typing_extensions.final +@typing.final class ListValue(google.protobuf.message.Message, google.protobuf.internal.well_known_types.ListValue): """`ListValue` is a wrapper around a repeated field of values. @@ -175,11 +179,12 @@ class ListValue(google.protobuf.message.Message, google.protobuf.internal.well_k @property def values(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Value]: """Repeated field of dynamically typed values.""" + def __init__( self, *, values: collections.abc.Iterable[global___Value] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["values", b"values"]) -> None: ... + def ClearField(self, field_name: typing.Literal["values", b"values"]) -> None: ... global___ListValue = ListValue diff --git a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi index 3f57f7602b6e..017a881de8b9 100644 --- a/stubs/protobuf/google/protobuf/timestamp_pb2.pyi +++ b/stubs/protobuf/google/protobuf/timestamp_pb2.pyi @@ -31,8 +31,9 @@ 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. """ + import builtins -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.internal.well_known_types @@ -40,7 +41,7 @@ import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Timestamp(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Timestamp): """A Timestamp represents a point in time independent of any time zone or local calendar, encoded as a count of seconds and fractions of seconds at @@ -154,6 +155,6 @@ class Timestamp(google.protobuf.message.Message, google.protobuf.internal.well_k seconds: builtins.int | None = ..., nanos: builtins.int | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... + def ClearField(self, field_name: typing.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... global___Timestamp = Timestamp diff --git a/stubs/protobuf/google/protobuf/type_pb2.pyi b/stubs/protobuf/google/protobuf/type_pb2.pyi index 60fcda720fc3..78e6b5b355a2 100644 --- a/stubs/protobuf/google/protobuf/type_pb2.pyi +++ b/stubs/protobuf/google/protobuf/type_pb2.pyi @@ -31,6 +31,7 @@ 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. """ + import builtins import collections.abc import sys @@ -74,7 +75,7 @@ SYNTAX_EDITIONS: Syntax.ValueType # 2 """Syntax `editions`.""" global___Syntax = Syntax -@typing_extensions.final +@typing.final class Type(google.protobuf.message.Message): """A protocol buffer message type.""" @@ -89,22 +90,26 @@ class Type(google.protobuf.message.Message): EDITION_FIELD_NUMBER: builtins.int name: builtins.str """The fully qualified message name.""" + syntax: global___Syntax.ValueType + """The source syntax.""" + edition: builtins.str + """The source edition string, only valid when syntax is SYNTAX_EDITIONS.""" @property def fields(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Field]: """The list of fields.""" + @property def oneofs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """The list of types appearing in `oneof` definitions in this type.""" + @property def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Option]: """The protocol buffer options.""" + @property def source_context(self) -> google.protobuf.source_context_pb2.SourceContext: """The source context.""" - syntax: global___Syntax.ValueType - """The source syntax.""" - edition: builtins.str - """The source edition string, only valid when syntax is SYNTAX_EDITIONS.""" + def __init__( self, *, @@ -116,12 +121,12 @@ class Type(google.protobuf.message.Message): syntax: global___Syntax.ValueType | None = ..., edition: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["source_context", b"source_context"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "fields", b"fields", "name", b"name", "oneofs", b"oneofs", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... + def HasField(self, field_name: typing.Literal["source_context", b"source_context"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["edition", b"edition", "fields", b"fields", "name", b"name", "oneofs", b"oneofs", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... global___Type = Type -@typing_extensions.final +@typing.final class Field(google.protobuf.message.Message): """A single field of a message type.""" @@ -269,13 +274,14 @@ class Field(google.protobuf.message.Message): """ packed: builtins.bool """Whether to use alternative packed wire representation.""" - @property - def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Option]: - """The protocol buffer options.""" json_name: builtins.str """The field JSON name.""" default_value: builtins.str """The string value of the default value of this field. Proto2 syntax only.""" + @property + def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Option]: + """The protocol buffer options.""" + def __init__( self, *, @@ -290,11 +296,11 @@ class Field(google.protobuf.message.Message): json_name: builtins.str | None = ..., default_value: builtins.str | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["cardinality", b"cardinality", "default_value", b"default_value", "json_name", b"json_name", "kind", b"kind", "name", b"name", "number", b"number", "oneof_index", b"oneof_index", "options", b"options", "packed", b"packed", "type_url", b"type_url"]) -> None: ... + def ClearField(self, field_name: typing.Literal["cardinality", b"cardinality", "default_value", b"default_value", "json_name", b"json_name", "kind", b"kind", "name", b"name", "number", b"number", "oneof_index", b"oneof_index", "options", b"options", "packed", b"packed", "type_url", b"type_url"]) -> None: ... global___Field = Field -@typing_extensions.final +@typing.final class Enum(google.protobuf.message.Message): """Enum type definition.""" @@ -308,19 +314,22 @@ class Enum(google.protobuf.message.Message): EDITION_FIELD_NUMBER: builtins.int name: builtins.str """Enum type name.""" + syntax: global___Syntax.ValueType + """The source syntax.""" + edition: builtins.str + """The source edition string, only valid when syntax is SYNTAX_EDITIONS.""" @property def enumvalue(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___EnumValue]: """Enum value definitions.""" + @property def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Option]: """Protocol buffer options.""" + @property def source_context(self) -> google.protobuf.source_context_pb2.SourceContext: """The source context.""" - syntax: global___Syntax.ValueType - """The source syntax.""" - edition: builtins.str - """The source edition string, only valid when syntax is SYNTAX_EDITIONS.""" + def __init__( self, *, @@ -331,12 +340,12 @@ class Enum(google.protobuf.message.Message): syntax: global___Syntax.ValueType | None = ..., edition: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["source_context", b"source_context"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["edition", b"edition", "enumvalue", b"enumvalue", "name", b"name", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... + def HasField(self, field_name: typing.Literal["source_context", b"source_context"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["edition", b"edition", "enumvalue", b"enumvalue", "name", b"name", "options", b"options", "source_context", b"source_context", "syntax", b"syntax"]) -> None: ... global___Enum = Enum -@typing_extensions.final +@typing.final class EnumValue(google.protobuf.message.Message): """Enum value definition.""" @@ -352,6 +361,7 @@ class EnumValue(google.protobuf.message.Message): @property def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Option]: """Protocol buffer options.""" + def __init__( self, *, @@ -359,11 +369,11 @@ class EnumValue(google.protobuf.message.Message): number: builtins.int | None = ..., options: collections.abc.Iterable[global___Option] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "number", b"number", "options", b"options"]) -> None: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "number", b"number", "options", b"options"]) -> None: ... global___EnumValue = EnumValue -@typing_extensions.final +@typing.final class Option(google.protobuf.message.Message): """A protocol buffer option, which can be attached to a message, field, enumeration, etc. @@ -386,13 +396,14 @@ class Option(google.protobuf.message.Message): should be used. If the value is an enum, it should be stored as an int32 value using the google.protobuf.Int32Value type. """ + def __init__( self, *, name: builtins.str | None = ..., value: google.protobuf.any_pb2.Any | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["value", b"value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "value", b"value"]) -> None: ... + def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "value", b"value"]) -> None: ... global___Option = Option diff --git a/stubs/protobuf/google/protobuf/wrappers_pb2.pyi b/stubs/protobuf/google/protobuf/wrappers_pb2.pyi index e87738c4d0f7..f3c923fea88b 100644 --- a/stubs/protobuf/google/protobuf/wrappers_pb2.pyi +++ b/stubs/protobuf/google/protobuf/wrappers_pb2.pyi @@ -41,15 +41,16 @@ the ability to detect presence on individual elements. These wrappers have no meaningful use within a map or a oneof since individual entries of a map or fields of a oneof can already detect presence. """ + import builtins -import typing as typing_extensions +import typing import google.protobuf.descriptor import google.protobuf.message DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class DoubleValue(google.protobuf.message.Message): """Wrapper message for `double`. @@ -66,11 +67,11 @@ class DoubleValue(google.protobuf.message.Message): *, value: builtins.float | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___DoubleValue = DoubleValue -@typing_extensions.final +@typing.final class FloatValue(google.protobuf.message.Message): """Wrapper message for `float`. @@ -87,11 +88,11 @@ class FloatValue(google.protobuf.message.Message): *, value: builtins.float | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___FloatValue = FloatValue -@typing_extensions.final +@typing.final class Int64Value(google.protobuf.message.Message): """Wrapper message for `int64`. @@ -108,11 +109,11 @@ class Int64Value(google.protobuf.message.Message): *, value: builtins.int | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___Int64Value = Int64Value -@typing_extensions.final +@typing.final class UInt64Value(google.protobuf.message.Message): """Wrapper message for `uint64`. @@ -129,11 +130,11 @@ class UInt64Value(google.protobuf.message.Message): *, value: builtins.int | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___UInt64Value = UInt64Value -@typing_extensions.final +@typing.final class Int32Value(google.protobuf.message.Message): """Wrapper message for `int32`. @@ -150,11 +151,11 @@ class Int32Value(google.protobuf.message.Message): *, value: builtins.int | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___Int32Value = Int32Value -@typing_extensions.final +@typing.final class UInt32Value(google.protobuf.message.Message): """Wrapper message for `uint32`. @@ -171,11 +172,11 @@ class UInt32Value(google.protobuf.message.Message): *, value: builtins.int | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___UInt32Value = UInt32Value -@typing_extensions.final +@typing.final class BoolValue(google.protobuf.message.Message): """Wrapper message for `bool`. @@ -192,11 +193,11 @@ class BoolValue(google.protobuf.message.Message): *, value: builtins.bool | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___BoolValue = BoolValue -@typing_extensions.final +@typing.final class StringValue(google.protobuf.message.Message): """Wrapper message for `string`. @@ -213,11 +214,11 @@ class StringValue(google.protobuf.message.Message): *, value: builtins.str | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___StringValue = StringValue -@typing_extensions.final +@typing.final class BytesValue(google.protobuf.message.Message): """Wrapper message for `bytes`. @@ -234,6 +235,6 @@ class BytesValue(google.protobuf.message.Message): *, value: builtins.bytes | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___BytesValue = BytesValue From fd0e36158af36b6d3fe4789955d9ef34aef533d0 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 8 Apr 2024 12:32:14 -0400 Subject: [PATCH 08/14] Fix stubtest and run stubdefaulter --- stubs/protobuf/google/protobuf/descriptor.pyi | 165 +++++++++--------- .../google/protobuf/descriptor_pool.pyi | 4 +- .../google/protobuf/internal/containers.pyi | 8 +- .../google/protobuf/internal/decoder.pyi | 6 +- .../protobuf/internal/well_known_types.pyi | 4 +- .../protobuf/google/protobuf/json_format.pyi | 34 ++-- stubs/protobuf/google/protobuf/message.pyi | 2 +- .../google/protobuf/message_factory.pyi | 4 +- .../protobuf/google/protobuf/text_format.pyi | 158 ++++++++--------- 9 files changed, 194 insertions(+), 191 deletions(-) diff --git a/stubs/protobuf/google/protobuf/descriptor.pyi b/stubs/protobuf/google/protobuf/descriptor.pyi index d8a1ad676ac4..fb9925e2187d 100644 --- a/stubs/protobuf/google/protobuf/descriptor.pyi +++ b/stubs/protobuf/google/protobuf/descriptor.pyi @@ -24,7 +24,7 @@ _USE_C_DESCRIPTORS: bool class DescriptorBase(metaclass=DescriptorMetaclass): has_options: Any - def __init__(self, options, serialized_options, options_class_name) -> None: ... + def __init__(self, file, options, serialized_options, options_class_name) -> None: ... def GetOptions(self): ... class _NestedDescriptorBase(DescriptorBase): @@ -40,9 +40,9 @@ class _NestedDescriptorBase(DescriptorBase): full_name, file, containing_type, - serialized_start=..., - serialized_end=..., - serialized_options=..., + serialized_start=None, + serialized_end=None, + serialized_options=None, ) -> None: ... def CopyToProto(self, proto): ... @@ -61,7 +61,8 @@ class Descriptor(_NestedDescriptorBase): extension_ranges: Any oneofs: Any oneofs_by_name: Any - syntax: Any + @property + def syntax(self): ... def __init__( self, name: str, @@ -72,16 +73,17 @@ class Descriptor(_NestedDescriptorBase): nested_types: list[FieldDescriptor], enum_types: list[EnumDescriptor], extensions: list[FieldDescriptor], - options: Incomplete | None = ..., - serialized_options: Incomplete | None = ..., - is_extendable: bool | None = ..., - extension_ranges: Incomplete | None = ..., - oneofs: list[OneofDescriptor] | None = ..., - file: FileDescriptor | None = ..., - serialized_start: Incomplete | None = ..., - serialized_end: Incomplete | None = ..., - syntax: str | None = ..., - create_key: Incomplete | None = ..., + options: Incomplete | None = None, + serialized_options: Incomplete | None = None, + is_extendable: bool | None = True, + extension_ranges: Incomplete | None = None, + oneofs: list[OneofDescriptor] | None = None, + file: FileDescriptor | None = None, + serialized_start: Incomplete | None = None, + serialized_end: Incomplete | None = None, + syntax: str | None = None, + is_map_entry=False, + create_key: Incomplete | None = None, ): ... def EnumValueName(self, enum, value): ... def CopyToProto(self, proto): ... @@ -140,13 +142,13 @@ class FieldDescriptor(DescriptorBase): containing_type, is_extension, extension_scope, - options=..., - serialized_options=..., - has_default_value=..., - containing_oneof=..., - json_name=..., - file=..., - create_key=..., + options=None, + serialized_options=None, + has_default_value=True, + containing_oneof=None, + json_name=None, + file=None, + create_key=None, ): ... name: Any full_name: Any @@ -178,13 +180,13 @@ class FieldDescriptor(DescriptorBase): containing_type, is_extension, extension_scope, - options=..., - serialized_options=..., - has_default_value=..., - containing_oneof=..., - json_name=..., - file=..., - create_key=..., + options=None, + serialized_options=None, + has_default_value=True, + containing_oneof=None, + json_name=None, + file=None, + create_key=None, ) -> None: ... @staticmethod def ProtoTypeToCppProtoType(proto_type): ... @@ -197,13 +199,13 @@ class EnumDescriptor(_NestedDescriptorBase): full_name, filename, values, - containing_type=..., - options=..., - serialized_options=..., - file=..., - serialized_start=..., - serialized_end=..., - create_key=..., + containing_type=None, + options=None, + serialized_options=None, + file=None, + serialized_start=None, + serialized_end=None, + create_key=None, ): ... values: Any values_by_name: Any @@ -214,35 +216,35 @@ class EnumDescriptor(_NestedDescriptorBase): full_name, filename, values, - containing_type=..., - options=..., - serialized_options=..., - file=..., - serialized_start=..., - serialized_end=..., - create_key=..., + containing_type=None, + options=None, + serialized_options=None, + file=None, + serialized_start=None, + serialized_end=None, + create_key=None, ) -> None: ... def CopyToProto(self, proto): ... def GetOptions(self) -> EnumOptions: ... class EnumValueDescriptor(DescriptorBase): - def __new__(cls, name, index, number, type=..., options=..., serialized_options=..., create_key=...): ... + def __new__(cls, name, index, number, type=None, options=None, serialized_options=None, create_key=None): ... name: Any index: Any number: Any type: Any - def __init__(self, name, index, number, type=..., options=..., serialized_options=..., create_key=...) -> None: ... + def __init__(self, name, index, number, type=None, options=None, serialized_options=None, create_key=None) -> None: ... def GetOptions(self) -> EnumValueOptions: ... class OneofDescriptor: - def __new__(cls, name, full_name, index, containing_type, fields, options=..., serialized_options=..., create_key=...): ... + def __new__(cls, name, full_name, index, containing_type, fields, options=None, serialized_options=None, create_key=None): ... name: Any full_name: Any index: Any containing_type: Any fields: Any def __init__( - self, name, full_name, index, containing_type, fields, options=..., serialized_options=..., create_key=... + self, name, full_name, index, containing_type, fields, options=None, serialized_options=None, create_key=None ) -> None: ... def GetOptions(self) -> OneofOptions: ... @@ -256,12 +258,12 @@ class ServiceDescriptor(_NestedDescriptorBase): full_name: str, index: int, methods: list[MethodDescriptor], - options: ServiceOptions | None = ..., - serialized_options: Incomplete | None = ..., - file: FileDescriptor | None = ..., - serialized_start: Incomplete | None = ..., - serialized_end: Incomplete | None = ..., - create_key: Incomplete | None = ..., + options: ServiceOptions | None = None, + serialized_options: Incomplete | None = None, + file: FileDescriptor | None = None, + serialized_start: Incomplete | None = None, + serialized_end: Incomplete | None = None, + create_key: Incomplete | None = None, ): ... def FindMethodByName(self, name): ... def CopyToProto(self, proto): ... @@ -276,11 +278,11 @@ class MethodDescriptor(DescriptorBase): containing_service, input_type, output_type, - client_streaming=..., - server_streaming=..., - options=..., - serialized_options=..., - create_key=..., + client_streaming=False, + server_streaming=False, + options=None, + serialized_options=None, + create_key=None, ): ... name: Any full_name: Any @@ -298,11 +300,11 @@ class MethodDescriptor(DescriptorBase): containing_service, input_type, output_type, - client_streaming=..., - server_streaming=..., - options=..., - serialized_options=..., - create_key=..., + client_streaming=False, + server_streaming=False, + options=None, + serialized_options=None, + create_key=None, ) -> None: ... def GetOptions(self) -> MethodOptions: ... @@ -311,21 +313,22 @@ class FileDescriptor(DescriptorBase): cls, name, package, - options=..., - serialized_options=..., - serialized_pb=..., - dependencies=..., - public_dependencies=..., - syntax=..., - pool=..., - create_key=..., + options=None, + serialized_options=None, + serialized_pb=None, + dependencies=None, + public_dependencies=None, + syntax=None, + pool=None, + create_key=None, ): ... _options: Any pool: Any message_types_by_name: Any name: Any package: Any - syntax: Any + @property + def syntax(self): ... serialized_pb: Any enum_types_by_name: Any extensions_by_name: Any @@ -336,17 +339,17 @@ class FileDescriptor(DescriptorBase): self, name, package, - options=..., - serialized_options=..., - serialized_pb=..., - dependencies=..., - public_dependencies=..., - syntax=..., - pool=..., - create_key=..., + options=None, + serialized_options=None, + serialized_pb=None, + dependencies=None, + public_dependencies=None, + syntax=None, + pool=None, + create_key=None, ) -> None: ... def CopyToProto(self, proto): ... def GetOptions(self) -> FileOptions: ... -def MakeDescriptor(desc_proto, package=..., build_file_if_cpp=..., syntax=...): ... +def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, syntax=None): ... def _ParseOptions(message: Message, string: bytes) -> Message: ... diff --git a/stubs/protobuf/google/protobuf/descriptor_pool.pyi b/stubs/protobuf/google/protobuf/descriptor_pool.pyi index 00be66656db7..75070bbabcfc 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pool.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pool.pyi @@ -1,9 +1,9 @@ from _typeshed import Incomplete class DescriptorPool: - def __new__(cls, descriptor_db: Incomplete | None = ...): ... + def __new__(cls, descriptor_db: Incomplete | None = None): ... def __init__( # pyright: ignore[reportInconsistentConstructor] - self, descriptor_db: Incomplete | None = ..., use_deprecated_legacy_json_field_conflicts: bool = ... + self, descriptor_db: Incomplete | None = None, use_deprecated_legacy_json_field_conflicts: bool = False ) -> None: ... def Add(self, file_desc_proto): ... def AddSerializedFile(self, serialized_file_desc_proto): ... diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index 235ab25d6185..5d5a2a3101ab 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -34,7 +34,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]): def extend(self, elem_seq: Iterable[_ScalarV] | None) -> None: ... def MergeFrom(self: _M, other: _M) -> None: ... def remove(self, elem: _ScalarV) -> None: ... - def pop(self, key: int = ...) -> _ScalarV: ... + def pop(self, key: int = -1) -> _ScalarV: ... @overload def __setitem__(self, key: int, value: _ScalarV) -> None: ... @overload @@ -50,7 +50,7 @@ class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]): def extend(self, elem_seq: Iterable[_MessageV]) -> None: ... def MergeFrom(self: _M, other: _M) -> None: ... def remove(self, elem: _MessageV) -> None: ... - def pop(self, key: int = ...) -> _MessageV: ... + def pop(self, key: int = -1) -> _MessageV: ... def __delitem__(self, key: int | slice) -> None: ... def __eq__(self, other: object) -> bool: ... @@ -69,7 +69,7 @@ class ScalarMap(MutableMapping[_K, _ScalarV]): def __iter__(self) -> Iterator[_K]: ... def __eq__(self, other: object) -> bool: ... @overload - def get(self, key: _K, default: None = ...) -> _ScalarV | None: ... + def get(self, key: _K, default: None = None) -> _ScalarV | None: ... @overload def get(self, key: _K, default: _ScalarV | _T) -> _ScalarV | _T: ... def MergeFrom(self: _M, other: _M): ... @@ -91,7 +91,7 @@ class MessageMap(MutableMapping[_K, _MessageV]): def __iter__(self) -> Iterator[_K]: ... def __eq__(self, other: object) -> bool: ... @overload - def get(self, key: _K, default: None = ...) -> _MessageV | None: ... + def get(self, key: _K, default: None = None) -> _MessageV | None: ... @overload def get(self, key: _K, default: _MessageV | _T) -> _MessageV | _T: ... def get_or_create(self, key: _K) -> _MessageV: ... diff --git a/stubs/protobuf/google/protobuf/internal/decoder.pyi b/stubs/protobuf/google/protobuf/internal/decoder.pyi index 41a50035b5e0..ce74e9318c60 100644 --- a/stubs/protobuf/google/protobuf/internal/decoder.pyi +++ b/stubs/protobuf/google/protobuf/internal/decoder.pyi @@ -30,7 +30,7 @@ def EnumDecoder( is_packed: bool, key: FieldDescriptor, new_default: _NewDefault, - clear_if_default: bool = ..., + clear_if_default: bool = False, ) -> _Decoder: ... def StringDecoder( field_number: int, @@ -38,7 +38,7 @@ def StringDecoder( is_packed: bool, key: FieldDescriptor, new_default: _NewDefault, - clear_if_default: bool = ..., + clear_if_default: bool = False, ) -> _Decoder: ... def BytesDecoder( field_number: int, @@ -46,7 +46,7 @@ def BytesDecoder( is_packed: bool, key: FieldDescriptor, new_default: _NewDefault, - clear_if_default: bool = ..., + clear_if_default: bool = False, ) -> _Decoder: ... def GroupDecoder( field_number: int, is_repeated: bool, is_packed: bool, key: FieldDescriptor, new_default: _NewDefault diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index e257cf052943..ae5db951e208 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -30,7 +30,7 @@ class Timestamp: def FromMicroseconds(self, micros: int) -> None: ... def FromMilliseconds(self, millis: int) -> None: ... def FromSeconds(self, seconds: int) -> None: ... - def ToDatetime(self, tzinfo: tzinfo | None = ...) -> datetime: ... + def ToDatetime(self, tzinfo: tzinfo | None = None) -> datetime: ... def FromDatetime(self, dt: datetime) -> None: ... class Duration: @@ -58,7 +58,7 @@ class FieldMask: def Union(self, mask1: tAny, mask2: tAny) -> None: ... def Intersect(self, mask1: tAny, mask2: tAny) -> None: ... def MergeMessage( - self, source: tAny, destination: tAny, replace_message_field: bool = ..., replace_repeated_field: bool = ... + self, source: tAny, destination: tAny, replace_message_field: bool = False, replace_repeated_field: bool = False ) -> None: ... class _FieldMaskTree: diff --git a/stubs/protobuf/google/protobuf/json_format.pyi b/stubs/protobuf/google/protobuf/json_format.pyi index 62ad1bad2e06..92cfc9708640 100644 --- a/stubs/protobuf/google/protobuf/json_format.pyi +++ b/stubs/protobuf/google/protobuf/json_format.pyi @@ -12,33 +12,33 @@ class SerializeToJsonError(Error): ... def MessageToJson( message: Message, including_default_value_fields: bool = ..., - preserving_proto_field_name: bool = ..., - indent: int | None = ..., - sort_keys: bool = ..., - use_integers_for_enums: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - float_precision: int | None = ..., - ensure_ascii: bool = ..., + preserving_proto_field_name: bool = False, + indent: int | None = 2, + sort_keys: bool = False, + use_integers_for_enums: bool = False, + descriptor_pool: DescriptorPool | None = None, + float_precision: int | None = None, + ensure_ascii: bool = True, ) -> str: ... def MessageToDict( message: Message, including_default_value_fields: bool = ..., - preserving_proto_field_name: bool = ..., - use_integers_for_enums: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - float_precision: int | None = ..., + preserving_proto_field_name: bool = False, + use_integers_for_enums: bool = False, + descriptor_pool: DescriptorPool | None = None, + float_precision: int | None = None, ) -> dict[str, Any]: ... def Parse( text: bytes | str, message: _MessageT, - ignore_unknown_fields: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - max_recursion_depth: int = ..., + ignore_unknown_fields: bool = False, + descriptor_pool: DescriptorPool | None = None, + max_recursion_depth: int = 100, ) -> _MessageT: ... def ParseDict( js_dict: Any, message: _MessageT, - ignore_unknown_fields: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - max_recursion_depth: int = ..., + ignore_unknown_fields: bool = False, + descriptor_pool: DescriptorPool | None = None, + max_recursion_depth: int = 100, ) -> _MessageT: ... diff --git a/stubs/protobuf/google/protobuf/message.pyi b/stubs/protobuf/google/protobuf/message.pyi index 64448454fcfb..83501d08da1b 100644 --- a/stubs/protobuf/google/protobuf/message.pyi +++ b/stubs/protobuf/google/protobuf/message.pyi @@ -13,7 +13,7 @@ _M = TypeVar("_M", bound=Message) # message type (of self) class Message: DESCRIPTOR: Descriptor - def __deepcopy__(self, memo: Any = ...) -> Self: ... + def __deepcopy__(self, memo: Any = None) -> Self: ... def __eq__(self, other_msg): ... def __ne__(self, other_msg): ... def MergeFrom(self, other_msg: Self) -> None: ... diff --git a/stubs/protobuf/google/protobuf/message_factory.pyi b/stubs/protobuf/google/protobuf/message_factory.pyi index e9009393aa62..518e1251955d 100644 --- a/stubs/protobuf/google/protobuf/message_factory.pyi +++ b/stubs/protobuf/google/protobuf/message_factory.pyi @@ -8,10 +8,10 @@ from google.protobuf.message import Message class MessageFactory: pool: Any - def __init__(self, pool: DescriptorPool | None = ...) -> None: ... + 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]]: ... -def GetMessages(file_protos: Iterable[FileDescriptorProto], pool: DescriptorPool | None = ...) -> dict[str, type[Message]]: ... +def GetMessages(file_protos: Iterable[FileDescriptorProto], pool: DescriptorPool | None = None) -> dict[str, type[Message]]: ... diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index 593739c94f04..bba614f9dc94 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -12,7 +12,7 @@ _M = TypeVar("_M", bound=Message) # message type (of self) class Error(Exception): ... class ParseError(Error): - def __init__(self, message: str | None = ..., line: int | None = ..., column: int | None = ...) -> None: ... + def __init__(self, message: str | None = None, line: int | None = None, column: int | None = None) -> None: ... def GetLine(self) -> int | None: ... def GetColumn(self) -> int | None: ... @@ -26,19 +26,19 @@ _MessageFormatter: TypeAlias = Callable[[Message, int, bool], str | None] def MessageToString( message: Message, - as_utf8: bool = ..., - as_one_line: bool = ..., - use_short_repeated_primitives: bool = ..., - pointy_brackets: bool = ..., - use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - indent: int = ..., - message_formatter: _MessageFormatter | None = ..., - print_unknown_fields: bool = ..., - force_colon: bool = ..., + as_utf8: bool = True, + as_one_line: bool = False, + use_short_repeated_primitives: bool = False, + pointy_brackets: bool = False, + use_index_order: bool = False, + float_format: str | None = None, + double_format: str | None = None, + use_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + indent: int = 0, + message_formatter: _MessageFormatter | None = None, + print_unknown_fields: bool = False, + force_colon: bool = False, ) -> str: ... def MessageToBytes( message: Message, @@ -59,51 +59,51 @@ def MessageToBytes( def PrintMessage( message: Message, out: SupportsWrite[str], - indent: int = ..., - as_utf8: bool = ..., - as_one_line: bool = ..., - use_short_repeated_primitives: bool = ..., - pointy_brackets: bool = ..., - use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - message_formatter: _MessageFormatter | None = ..., - print_unknown_fields: bool = ..., - force_colon: bool = ..., + indent: int = 0, + as_utf8: bool = True, + as_one_line: bool = False, + use_short_repeated_primitives: bool = False, + pointy_brackets: bool = False, + use_index_order: bool = False, + float_format: str | None = None, + double_format: str | None = None, + use_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + message_formatter: _MessageFormatter | None = None, + print_unknown_fields: bool = False, + force_colon: bool = False, ) -> None: ... def PrintField( field: FieldDescriptor, value: Any, out: SupportsWrite[str], - indent: int = ..., - as_utf8: bool = ..., - as_one_line: bool = ..., - use_short_repeated_primitives: bool = ..., - pointy_brackets: bool = ..., - use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - message_formatter: _MessageFormatter | None = ..., - print_unknown_fields: bool = ..., - force_colon: bool = ..., + indent: int = 0, + as_utf8: bool = True, + as_one_line: bool = False, + use_short_repeated_primitives: bool = False, + pointy_brackets: bool = False, + use_index_order: bool = False, + float_format: str | None = None, + double_format: str | None = None, + message_formatter: _MessageFormatter | None = None, + print_unknown_fields: bool = False, + force_colon: bool = False, ) -> None: ... def PrintFieldValue( field: FieldDescriptor, value: Any, out: SupportsWrite[str], - indent: int = ..., - as_utf8: bool = ..., - as_one_line: bool = ..., - use_short_repeated_primitives: bool = ..., - pointy_brackets: bool = ..., - use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - message_formatter: _MessageFormatter | None = ..., - print_unknown_fields: bool = ..., - force_colon: bool = ..., + indent: int = 0, + as_utf8: bool = True, + as_one_line: bool = False, + use_short_repeated_primitives: bool = False, + pointy_brackets: bool = False, + use_index_order: bool = False, + float_format: str | None = None, + double_format: str | None = None, + message_formatter: _MessageFormatter | None = None, + print_unknown_fields: bool = False, + force_colon: bool = False, ) -> None: ... class _Printer: @@ -124,19 +124,19 @@ class _Printer: def __init__( self, out: SupportsWrite[str], - indent: int = ..., - as_utf8: bool = ..., - as_one_line: bool = ..., - use_short_repeated_primitives: bool = ..., - pointy_brackets: bool = ..., - use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - message_formatter: _MessageFormatter | None = ..., - print_unknown_fields: bool = ..., - force_colon: bool = ..., + indent: int = 0, + as_utf8: bool = True, + as_one_line: bool = False, + use_short_repeated_primitives: bool = False, + pointy_brackets: bool = False, + use_index_order: bool = False, + float_format: str | None = None, + double_format: str | None = None, + use_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + message_formatter: _MessageFormatter | None = None, + print_unknown_fields: bool = False, + force_colon: bool = False, ) -> None: ... def PrintMessage(self, message: Message) -> None: ... def PrintField(self, field: FieldDescriptor, value: Any) -> None: ... @@ -145,26 +145,26 @@ class _Printer: def Parse( text: str | bytes, message: _M, - allow_unknown_extension: bool = ..., - allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - allow_unknown_field: bool = ..., + allow_unknown_extension: bool = False, + allow_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + allow_unknown_field: bool = False, ) -> _M: ... def Merge( text: str | bytes, message: _M, - allow_unknown_extension: bool = ..., - allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - allow_unknown_field: bool = ..., + allow_unknown_extension: bool = False, + allow_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + allow_unknown_field: bool = False, ) -> _M: ... def MergeLines( lines: Iterable[str | bytes], message: _M, - allow_unknown_extension: bool = ..., - allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - allow_unknown_field: bool = ..., + allow_unknown_extension: bool = False, + allow_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + allow_unknown_field: bool = False, ) -> _M: ... class _Parser: @@ -174,10 +174,10 @@ class _Parser: allow_unknown_field: bool def __init__( self, - allow_unknown_extension: bool = ..., - allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - allow_unknown_field: bool = ..., + allow_unknown_extension: bool = False, + allow_field_number: bool = False, + descriptor_pool: DescriptorPool | None = None, + allow_unknown_field: bool = False, ) -> None: ... def ParseLines(self, lines: Iterable[str | bytes], message: _M) -> _M: ... def MergeLines(self, lines: Iterable[str | bytes], message: _M) -> _M: ... @@ -210,7 +210,7 @@ class Tokenizer: def ParseError(self, message: Message) -> _ParseError: ... def NextToken(self) -> None: ... -def ParseInteger(text: str, is_signed: bool = ..., is_long: bool = ...) -> int: ... +def ParseInteger(text: str, is_signed: bool = False, is_long: bool = False) -> int: ... def ParseFloat(text: str) -> float: ... def ParseBool(text: str) -> bool: ... def ParseEnum(field: FieldDescriptor, value: str) -> int: ... From 7ebeb6decdf7431c9f8cf5bc036a2ec346adfa18 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:37:42 +0000 Subject: [PATCH 09/14] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/protobuf/google/protobuf/descriptor.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/protobuf/google/protobuf/descriptor.pyi b/stubs/protobuf/google/protobuf/descriptor.pyi index fb9925e2187d..bd33ffabeea1 100644 --- a/stubs/protobuf/google/protobuf/descriptor.pyi +++ b/stubs/protobuf/google/protobuf/descriptor.pyi @@ -351,5 +351,5 @@ class FileDescriptor(DescriptorBase): def CopyToProto(self, proto): ... def GetOptions(self) -> FileOptions: ... -def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, syntax=None): ... +def MakeDescriptor(desc_proto, package="", build_file_if_cpp=True, syntax=None): ... def _ParseOptions(message: Message, string: bytes) -> Message: ... From 0498d92b5d4d5e5d400c11daf061c95897d480d1 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 8 Apr 2024 12:45:47 -0400 Subject: [PATCH 10/14] fixes --- stubs/protobuf/google/protobuf/json_format.pyi | 4 ++-- stubs/protobuf/google/protobuf/text_format.pyi | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/stubs/protobuf/google/protobuf/json_format.pyi b/stubs/protobuf/google/protobuf/json_format.pyi index 92cfc9708640..2f9a82cee794 100644 --- a/stubs/protobuf/google/protobuf/json_format.pyi +++ b/stubs/protobuf/google/protobuf/json_format.pyi @@ -11,7 +11,7 @@ class SerializeToJsonError(Error): ... def MessageToJson( message: Message, - including_default_value_fields: bool = ..., + including_default_value_fields: bool = False, preserving_proto_field_name: bool = False, indent: int | None = 2, sort_keys: bool = False, @@ -22,7 +22,7 @@ def MessageToJson( ) -> str: ... def MessageToDict( message: Message, - including_default_value_fields: bool = ..., + including_default_value_fields: bool = False, preserving_proto_field_name: bool = False, use_integers_for_enums: bool = False, descriptor_pool: DescriptorPool | None = None, diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index bba614f9dc94..52467d9fef97 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -26,7 +26,7 @@ _MessageFormatter: TypeAlias = Callable[[Message, int, bool], str | None] def MessageToString( message: Message, - as_utf8: bool = True, + as_utf8: bool = False, as_one_line: bool = False, use_short_repeated_primitives: bool = False, pointy_brackets: bool = False, @@ -60,7 +60,7 @@ def PrintMessage( message: Message, out: SupportsWrite[str], indent: int = 0, - as_utf8: bool = True, + as_utf8: bool = False, as_one_line: bool = False, use_short_repeated_primitives: bool = False, pointy_brackets: bool = False, @@ -78,7 +78,7 @@ def PrintField( value: Any, out: SupportsWrite[str], indent: int = 0, - as_utf8: bool = True, + as_utf8: bool = False, as_one_line: bool = False, use_short_repeated_primitives: bool = False, pointy_brackets: bool = False, @@ -94,7 +94,7 @@ def PrintFieldValue( value: Any, out: SupportsWrite[str], indent: int = 0, - as_utf8: bool = True, + as_utf8: bool = False, as_one_line: bool = False, use_short_repeated_primitives: bool = False, pointy_brackets: bool = False, @@ -125,7 +125,7 @@ class _Printer: self, out: SupportsWrite[str], indent: int = 0, - as_utf8: bool = True, + as_utf8: bool = False, as_one_line: bool = False, use_short_repeated_primitives: bool = False, pointy_brackets: bool = False, From afc6213e8b47c2cf3de1630e49ed550a70eca6fe Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 8 Apr 2024 12:50:24 -0400 Subject: [PATCH 11/14] post-merge accidental changes in sync_tensorflow --- scripts/sync_tensorflow_protobuf_stubs.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 29b603c810bd..b6458d937c69 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -61,13 +61,18 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi -# use `|| true` so the script still continues even if a pre-commit hook -# applies autofixes (which will result in a nonzero exit code) -pre-commit run --files "$REPO_ROOT/stubs/tensorflow/tensorflow" || true - sed --in-place="" \ "s/extra_description = .*$/extra_description = \"Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on tensorflow==$TENSORFLOW_VERSION\"/" \ "$REPO_ROOT/stubs/tensorflow/METADATA.toml" # Cleanup last. If the script fails halfway, it's nice to be able to re-run it immediately rm -rf repository/ + +# Must be run in a git repository +cd $REPO_ROOT +# use `|| true` so the script still continues even if a pre-commit hook +# applies autofixes (which will result in a nonzero exit code) +pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/tensorflow/tensorflow") || true +# Ruff takes two passes to fix everything, re-running all of pre-commit is *slow* +# and we don't need --unsafe-fixes to remove imports +ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix --exit-zero From a8a3985a123d95e7e09afbea13218b608beb8a71 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 8 Apr 2024 13:02:00 -0400 Subject: [PATCH 12/14] Apply suggestions from code review Further filter pre-commit run in generated scripts --- scripts/generate_proto_stubs.sh | 2 +- scripts/sync_tensorflow_protobuf_stubs.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 62618adf3de4..0401de4fda9c 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -79,4 +79,4 @@ sed --in-place="" \ cd $REPO_ROOT # use `|| true` so the script still continues even if a pre-commit hook # applies autofixes (which will result in a nonzero exit code) -pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf/**.pyi") || true +pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf/**_pb2.pyi") || true diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index b6458d937c69..3de1895324a5 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -61,6 +61,7 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi + sed --in-place="" \ "s/extra_description = .*$/extra_description = \"Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) on tensorflow==$TENSORFLOW_VERSION\"/" \ "$REPO_ROOT/stubs/tensorflow/METADATA.toml" From 4c073b32c87d3d01fa953c3f83e89167f6297a83 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 9 Apr 2024 13:37:43 -0400 Subject: [PATCH 13/14] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b65e0e533b1..caab9ddcd620 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,15 +13,14 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.3.5 # must match requirements-tests.txt hooks: + - id: ruff + name: Run ruff on stubs, tests and scripts + args: ["--exit-non-zero-on-fix"] - id: ruff # Run this separately because we don't really want # to use --unsafe-fixes for all rules - # Should be run first as it can leave unused imports behind name: Remove unnecessary `sys.version_info` blocks args: ["--exit-non-zero-on-fix", "--select=UP036", "--unsafe-fixes"] - - id: ruff - name: Run ruff on stubs, tests and scripts - args: ["--exit-non-zero-on-fix"] - id: ruff # Very few rules are useful to run on our test cases; # we explicitly enumerate them here: From c94f639b61792d0814c4283d05424f6029007229 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 9 Apr 2024 13:38:35 -0400 Subject: [PATCH 14/14] Adding quotes around variable in case of spaces --- scripts/generate_proto_stubs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 0401de4fda9c..74aac79a57c8 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -76,7 +76,7 @@ sed --in-place="" \ "$REPO_ROOT/stubs/protobuf/METADATA.toml" # Must be run in a git repository -cd $REPO_ROOT +cd "$REPO_ROOT" # use `|| true` so the script still continues even if a pre-commit hook # applies autofixes (which will result in a nonzero exit code) pre-commit run --files $(git ls-files -- "$REPO_ROOT/stubs/protobuf/**_pb2.pyi") || true