mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Bump protobuf to 5.26.* (#11784)
Also update generate_proto_stubs script
This commit is contained in:
@@ -12,14 +12,15 @@ set -ex -o pipefail
|
||||
#
|
||||
# Whenever you update PROTOBUF_VERSION here, version should be updated
|
||||
# in stubs/protobuf/METADATA.toml and vice-versa.
|
||||
PROTOBUF_VERSION=25.3
|
||||
PROTOBUF_VERSION=26.1
|
||||
MYPY_PROTOBUF_VERSION=3.6.0
|
||||
|
||||
if uname -a | grep Darwin; then
|
||||
# brew install coreutils wget
|
||||
PLAT=osx
|
||||
# brew install coreutils wget
|
||||
PLAT=osx
|
||||
else
|
||||
PLAT=linux
|
||||
# sudo apt install -y unzip
|
||||
PLAT=linux
|
||||
fi
|
||||
REPO_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
@@ -51,19 +52,13 @@ python3 -m pip install pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION"
|
||||
find "$REPO_ROOT/stubs/protobuf/" -name '*_pb2.pyi' -delete
|
||||
|
||||
# Roughly reproduce the subset of .proto files on the public interface as described
|
||||
# by find_package_modules in the protobuf setup.py.
|
||||
# The logic (as of 3.20.1) can roughly be described as a allowlist of .proto files
|
||||
# further limited to exclude *test* and internal/
|
||||
# https://github.com/protocolbuffers/protobuf/blob/master/python/setup.py
|
||||
PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \
|
||||
cut -d\' -f2 | \
|
||||
grep -v "test" | \
|
||||
grep -v google/protobuf/internal/ | \
|
||||
grep -v google/protobuf/pyext/python.proto | \
|
||||
grep -v src/google/protobuf/util/json_format.proto | \
|
||||
grep -v src/google/protobuf/util/json_format_proto3.proto | \
|
||||
sed "s:^:$PYTHON_PROTOBUF_DIR/python/:" | \
|
||||
xargs -L1 realpath --relative-to=. \
|
||||
# in py_proto_library calls in
|
||||
# https://github.com/protocolbuffers/protobuf/blob/main/python/dist/BUILD.bazel
|
||||
PROTO_FILES=$(grep '"//:.*_proto"' $PYTHON_PROTOBUF_DIR/python/dist/BUILD.bazel | \
|
||||
cut -d\" -f2 | \
|
||||
sed "s://\::$PYTHON_PROTOBUF_DIR/src/google/protobuf/:" | \
|
||||
sed "s:_proto:.proto:" | \
|
||||
sed "s:compiler_:compiler/:" \
|
||||
)
|
||||
|
||||
# And regenerate!
|
||||
|
||||
@@ -13,12 +13,8 @@ google.protobuf.message.Message.DESCRIPTOR
|
||||
# See https://github.com/protocolbuffers/protobuf/blob/3ea30d80847cd9561db570ae7f673afc15523545/python/google/protobuf/message.py#L67
|
||||
google.protobuf.message.Message.Extensions
|
||||
|
||||
# These are typed as (self, **kwargs) at runtime as thin wrapper functions
|
||||
# around the underlying true typing. We prefer the true typing
|
||||
# Has *args that would fail at runtime with any positional argument
|
||||
google.protobuf.internal.containers.BaseContainer.sort
|
||||
google.protobuf.message.Message.SerializePartialToString
|
||||
google.protobuf.message.Message.SerializeToString
|
||||
google.protobuf.text_format.MessageToBytes
|
||||
|
||||
# Stubbed as static method, but actually exists as a property that's
|
||||
# a function. Typeshed's typing is more useful
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Whenever you update version here, PROTOBUF_VERSION should be updated
|
||||
# in scripts/generate_proto_stubs.sh and vice-versa.
|
||||
version = "4.25.*"
|
||||
version = "5.26.*"
|
||||
upstream_repository = "https://github.com/protocolbuffers/protobuf"
|
||||
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)"
|
||||
extra_description = "Generated using [mypy-protobuf==3.6.0](https://github.com/nipunn1313/mypy-protobuf/tree/v3.6.0) on [protobuf v26.1](https://github.com/protocolbuffers/protobuf/releases/tag/v26.1) (python protobuf==5.26.1)"
|
||||
partial_stub = true
|
||||
|
||||
[tool.stubtest]
|
||||
|
||||
@@ -238,6 +238,8 @@ class CodeGeneratorResponse(google.protobuf.message.Message):
|
||||
|
||||
ERROR_FIELD_NUMBER: builtins.int
|
||||
SUPPORTED_FEATURES_FIELD_NUMBER: builtins.int
|
||||
MINIMUM_EDITION_FIELD_NUMBER: builtins.int
|
||||
MAXIMUM_EDITION_FIELD_NUMBER: builtins.int
|
||||
FILE_FIELD_NUMBER: builtins.int
|
||||
error: builtins.str
|
||||
"""Error message. If non-empty, code generation failed. The plugin process
|
||||
@@ -253,6 +255,18 @@ class CodeGeneratorResponse(google.protobuf.message.Message):
|
||||
"""A bitmask of supported features that the code generator supports.
|
||||
This is a bitwise "or" of values from the Feature enum.
|
||||
"""
|
||||
minimum_edition: builtins.int
|
||||
"""The minimum edition this plugin supports. This will be treated as an
|
||||
Edition enum, but we want to allow unknown values. It should be specified
|
||||
according the edition enum value, *not* the edition number. Only takes
|
||||
effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
|
||||
"""
|
||||
maximum_edition: builtins.int
|
||||
"""The maximum edition this plugin supports. This will be treated as an
|
||||
Edition enum, but we want to allow unknown values. It should be specified
|
||||
according the edition enum value, *not* the edition number. Only takes
|
||||
effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
|
||||
"""
|
||||
@property
|
||||
def file(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___CodeGeneratorResponse.File]: ...
|
||||
def __init__(
|
||||
@@ -260,9 +274,11 @@ class CodeGeneratorResponse(google.protobuf.message.Message):
|
||||
*,
|
||||
error: builtins.str | None = ...,
|
||||
supported_features: builtins.int | None = ...,
|
||||
minimum_edition: builtins.int | None = ...,
|
||||
maximum_edition: builtins.int | None = ...,
|
||||
file: collections.abc.Iterable[global___CodeGeneratorResponse.File] | None = ...,
|
||||
) -> 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: ...
|
||||
def HasField(self, field_name: typing.Literal["error", b"error", "maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition", "supported_features", b"supported_features"]) -> builtins.bool: ...
|
||||
def ClearField(self, field_name: typing.Literal["error", b"error", "file", b"file", "maximum_edition", b"maximum_edition", "minimum_edition", b"minimum_edition", "supported_features", b"supported_features"]) -> None: ...
|
||||
|
||||
global___CodeGeneratorResponse = CodeGeneratorResponse
|
||||
|
||||
@@ -61,8 +61,6 @@ class Descriptor(_NestedDescriptorBase):
|
||||
extension_ranges: Any
|
||||
oneofs: Any
|
||||
oneofs_by_name: Any
|
||||
@property
|
||||
def syntax(self): ...
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
@@ -156,7 +154,8 @@ class FieldDescriptor(DescriptorBase):
|
||||
number: Any
|
||||
type: Any
|
||||
cpp_type: Any
|
||||
label: Any
|
||||
@property
|
||||
def label(self): ...
|
||||
has_default_value: Any
|
||||
default_value: Any
|
||||
containing_type: Any
|
||||
@@ -319,6 +318,7 @@ class FileDescriptor(DescriptorBase):
|
||||
dependencies=None,
|
||||
public_dependencies=None,
|
||||
syntax=None,
|
||||
edition=None,
|
||||
pool=None,
|
||||
create_key=None,
|
||||
): ...
|
||||
@@ -327,8 +327,6 @@ class FileDescriptor(DescriptorBase):
|
||||
message_types_by_name: Any
|
||||
name: Any
|
||||
package: Any
|
||||
@property
|
||||
def syntax(self): ...
|
||||
serialized_pb: Any
|
||||
enum_types_by_name: Any
|
||||
extensions_by_name: Any
|
||||
@@ -345,11 +343,12 @@ class FileDescriptor(DescriptorBase):
|
||||
dependencies=None,
|
||||
public_dependencies=None,
|
||||
syntax=None,
|
||||
edition=None,
|
||||
pool=None,
|
||||
create_key=None,
|
||||
) -> None: ...
|
||||
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, edition=None, file_desc=None): ...
|
||||
def _ParseOptions(message: Message, string: bytes) -> Message: ...
|
||||
|
||||
@@ -47,6 +47,7 @@ class _EditionEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTy
|
||||
should not be depended on, but they will always be time-ordered for easy
|
||||
comparison.
|
||||
"""
|
||||
EDITION_2024: _Edition.ValueType # 1001
|
||||
EDITION_1_TEST_ONLY: _Edition.ValueType # 1
|
||||
"""Placeholder editions for testing feature resolution. These should not be
|
||||
used or relyed on outside of tests.
|
||||
@@ -55,6 +56,11 @@ class _EditionEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTy
|
||||
EDITION_99997_TEST_ONLY: _Edition.ValueType # 99997
|
||||
EDITION_99998_TEST_ONLY: _Edition.ValueType # 99998
|
||||
EDITION_99999_TEST_ONLY: _Edition.ValueType # 99999
|
||||
EDITION_MAX: _Edition.ValueType # 2147483647
|
||||
"""Placeholder for specifying unbounded edition support. This should only
|
||||
ever be used by plugins that can expect to never require any changes to
|
||||
support a new edition.
|
||||
"""
|
||||
|
||||
class Edition(_Edition, metaclass=_EditionEnumTypeWrapper):
|
||||
"""The full set of known editions."""
|
||||
@@ -73,6 +79,7 @@ EDITION_2023: Edition.ValueType # 1000
|
||||
should not be depended on, but they will always be time-ordered for easy
|
||||
comparison.
|
||||
"""
|
||||
EDITION_2024: Edition.ValueType # 1001
|
||||
EDITION_1_TEST_ONLY: Edition.ValueType # 1
|
||||
"""Placeholder editions for testing feature resolution. These should not be
|
||||
used or relyed on outside of tests.
|
||||
@@ -81,6 +88,11 @@ 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
|
||||
EDITION_MAX: Edition.ValueType # 2147483647
|
||||
"""Placeholder for specifying unbounded edition support. This should only
|
||||
ever be used by plugins that can expect to never require any changes to
|
||||
support a new edition.
|
||||
"""
|
||||
global___Edition = Edition
|
||||
|
||||
@typing.final
|
||||
@@ -557,12 +569,12 @@ class FieldDescriptorProto(google.protobuf.message.Message):
|
||||
"""If true, this is a proto3 "optional". When a proto3 field is optional, it
|
||||
tracks presence regardless of field type.
|
||||
|
||||
When proto3_optional is true, this field must be belong to a oneof to
|
||||
signal to old proto3 clients that presence is tracked for this field. This
|
||||
oneof is known as a "synthetic" oneof, and this field must be its sole
|
||||
member (each proto3 optional field gets its own synthetic oneof). Synthetic
|
||||
oneofs exist in the descriptor only, and do not generate any API. Synthetic
|
||||
oneofs must be ordered after all "real" oneofs.
|
||||
When proto3_optional is true, this field must belong to a oneof to signal
|
||||
to old proto3 clients that presence is tracked for this field. This oneof
|
||||
is known as a "synthetic" oneof, and this field must be its sole member
|
||||
(each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
|
||||
exist in the descriptor only, and do not generate any API. Synthetic oneofs
|
||||
must be ordered after all "real" oneofs.
|
||||
|
||||
For message fields, proto3_optional doesn't create any semantic change,
|
||||
since non-repeated message fields always track presence. However it still
|
||||
@@ -851,7 +863,6 @@ class FileOptions(google.protobuf.message.Message):
|
||||
CC_GENERIC_SERVICES_FIELD_NUMBER: builtins.int
|
||||
JAVA_GENERIC_SERVICES_FIELD_NUMBER: builtins.int
|
||||
PY_GENERIC_SERVICES_FIELD_NUMBER: builtins.int
|
||||
PHP_GENERIC_SERVICES_FIELD_NUMBER: builtins.int
|
||||
DEPRECATED_FIELD_NUMBER: builtins.int
|
||||
CC_ENABLE_ARENAS_FIELD_NUMBER: builtins.int
|
||||
OBJC_CLASS_PREFIX_FIELD_NUMBER: builtins.int
|
||||
@@ -916,7 +927,6 @@ class FileOptions(google.protobuf.message.Message):
|
||||
"""
|
||||
java_generic_services: builtins.bool
|
||||
py_generic_services: builtins.bool
|
||||
php_generic_services: builtins.bool
|
||||
deprecated: builtins.bool
|
||||
"""Is this file deprecated?
|
||||
Depending on the target platform, this can emit Deprecated annotations
|
||||
@@ -981,7 +991,6 @@ class FileOptions(google.protobuf.message.Message):
|
||||
cc_generic_services: builtins.bool | None = ...,
|
||||
java_generic_services: builtins.bool | None = ...,
|
||||
py_generic_services: builtins.bool | None = ...,
|
||||
php_generic_services: builtins.bool | None = ...,
|
||||
deprecated: builtins.bool | None = ...,
|
||||
cc_enable_arenas: builtins.bool | None = ...,
|
||||
objc_class_prefix: builtins.str | None = ...,
|
||||
@@ -994,8 +1003,8 @@ 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.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: ...
|
||||
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_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_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
|
||||
|
||||
@@ -1042,11 +1051,7 @@ class MessageOptions(google.protobuf.message.Message):
|
||||
this is a formalization for deprecating messages.
|
||||
"""
|
||||
map_entry: builtins.bool
|
||||
"""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
|
||||
"""Whether the message is an automatically generated map entry type for the
|
||||
maps field.
|
||||
|
||||
For maps fields:
|
||||
@@ -1063,6 +1068,10 @@ 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.
|
||||
|
||||
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.
|
||||
"""
|
||||
deprecated_legacy_json_field_conflicts: builtins.bool
|
||||
"""Enable the legacy handling of JSON field name conflicts. This lowercases
|
||||
@@ -1290,19 +1299,11 @@ 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.
|
||||
This is necessary because otherwise the inner message would have to be
|
||||
parsed in order to perform the check, defeating the purpose of lazy
|
||||
parsing. An implementation which chooses not to check required fields
|
||||
must be consistent about it. That is, for any particular sub-message, the
|
||||
implementation must either *always* check its required fields, or *never*
|
||||
check its required fields, regardless of whether or not the message has
|
||||
been parsed.
|
||||
|
||||
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.
|
||||
Note that lazy message fields are still eagerly verified to check
|
||||
ill-formed wireformat or missing required fields. Calling IsInitialized()
|
||||
on the outer message would fail if the inner message has missing required
|
||||
fields. Failed verification would result in parsing failure (except when
|
||||
uninitialized messages are acceptable).
|
||||
"""
|
||||
unverified_lazy: builtins.bool
|
||||
"""unverified_lazy does no correctness checks on the byte stream. This should
|
||||
@@ -1712,13 +1713,13 @@ class FeatureSet(google.protobuf.message.Message):
|
||||
class _Utf8ValidationEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[FeatureSet._Utf8Validation.ValueType], builtins.type):
|
||||
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
|
||||
UTF8_VALIDATION_UNKNOWN: FeatureSet._Utf8Validation.ValueType # 0
|
||||
NONE: FeatureSet._Utf8Validation.ValueType # 1
|
||||
VERIFY: FeatureSet._Utf8Validation.ValueType # 2
|
||||
NONE: FeatureSet._Utf8Validation.ValueType # 3
|
||||
|
||||
class Utf8Validation(_Utf8Validation, metaclass=_Utf8ValidationEnumTypeWrapper): ...
|
||||
UTF8_VALIDATION_UNKNOWN: FeatureSet.Utf8Validation.ValueType # 0
|
||||
NONE: FeatureSet.Utf8Validation.ValueType # 1
|
||||
VERIFY: FeatureSet.Utf8Validation.ValueType # 2
|
||||
NONE: FeatureSet.Utf8Validation.ValueType # 3
|
||||
|
||||
class _MessageEncoding:
|
||||
ValueType = typing.NewType("ValueType", builtins.int)
|
||||
@@ -1912,7 +1913,7 @@ class SourceCodeInfo(google.protobuf.message.Message):
|
||||
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.
|
||||
the root FileDescriptorProto to the place where the definition appears.
|
||||
For example, this path:
|
||||
[ 4, 3, 2, 7, 1 ]
|
||||
refers to:
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
from _typeshed import Incomplete
|
||||
from _typeshed import Incomplete, Unused
|
||||
|
||||
class DescriptorPool:
|
||||
def __new__(cls, descriptor_db: Incomplete | None = None): ...
|
||||
def __init__( # pyright: ignore[reportInconsistentConstructor]
|
||||
self, descriptor_db: Incomplete | None = None, use_deprecated_legacy_json_field_conflicts: bool = False
|
||||
self, descriptor_db: Incomplete | None = None, use_deprecated_legacy_json_field_conflicts: Unused = False
|
||||
) -> None: ...
|
||||
def Add(self, file_desc_proto): ...
|
||||
def AddSerializedFile(self, serialized_file_desc_proto): ...
|
||||
def AddDescriptor(self, desc): ...
|
||||
def AddServiceDescriptor(self, service_desc): ...
|
||||
def AddExtensionDescriptor(self, extension): ...
|
||||
def AddFileDescriptor(self, file_desc): ...
|
||||
def FindFileByName(self, file_name): ...
|
||||
def FindFileContainingSymbol(self, symbol): ...
|
||||
def FindMessageTypeByName(self, full_name): ...
|
||||
|
||||
@@ -21,7 +21,8 @@ class BaseContainer(Sequence[_T]):
|
||||
def __len__(self) -> int: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def sort(self, *, key: Callable[[_T], Any] | None = ..., reverse: bool = ...) -> None: ...
|
||||
# Same as list.sort, the extra sort_function kwarg errors in Python 3
|
||||
def sort(self, *, key: Callable[[_T], Any] | None = None, reverse: bool = False) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, key: SupportsIndex) -> _T: ...
|
||||
@overload
|
||||
|
||||
@@ -11,7 +11,6 @@ class SerializeToJsonError(Error): ...
|
||||
|
||||
def MessageToJson(
|
||||
message: Message,
|
||||
including_default_value_fields: bool = False,
|
||||
preserving_proto_field_name: bool = False,
|
||||
indent: int | None = 2,
|
||||
sort_keys: bool = False,
|
||||
@@ -19,10 +18,11 @@ def MessageToJson(
|
||||
descriptor_pool: DescriptorPool | None = None,
|
||||
float_precision: int | None = None,
|
||||
ensure_ascii: bool = True,
|
||||
always_print_fields_with_no_presence: bool = False,
|
||||
) -> str: ...
|
||||
def MessageToDict(
|
||||
message: Message,
|
||||
including_default_value_fields: bool = False,
|
||||
always_print_fields_with_no_presence: bool = False,
|
||||
preserving_proto_field_name: bool = False,
|
||||
use_integers_for_enums: bool = False,
|
||||
descriptor_pool: DescriptorPool | None = None,
|
||||
|
||||
@@ -23,8 +23,8 @@ class Message:
|
||||
def IsInitialized(self) -> bool: ...
|
||||
def MergeFromString(self, serialized: bytes) -> int: ...
|
||||
def ParseFromString(self, serialized: bytes) -> int: ...
|
||||
def SerializeToString(self, deterministic: bool = ...) -> bytes: ...
|
||||
def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ...
|
||||
def SerializeToString(self, *, deterministic: bool = ...) -> bytes: ...
|
||||
def SerializePartialToString(self, *, deterministic: bool = ...) -> bytes: ...
|
||||
def ListFields(self) -> Sequence[tuple[FieldDescriptor, Any]]: ...
|
||||
# The TypeVar must be bound to `Message` or we get mypy errors, so we cannot use `Self` for `HasExtension` & `ClearExtension`
|
||||
def HasExtension(self: _M, field_descriptor: _ExtensionFieldDescriptor[_M, Any]) -> bool: ...
|
||||
|
||||
@@ -26,7 +26,7 @@ _MessageFormatter: TypeAlias = Callable[[Message, int, bool], str | None]
|
||||
|
||||
def MessageToString(
|
||||
message: Message,
|
||||
as_utf8: bool = False,
|
||||
as_utf8: bool = True,
|
||||
as_one_line: bool = False,
|
||||
use_short_repeated_primitives: bool = False,
|
||||
pointy_brackets: bool = False,
|
||||
@@ -42,25 +42,27 @@ def MessageToString(
|
||||
) -> str: ...
|
||||
def MessageToBytes(
|
||||
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 = ...,
|
||||
print_unknown_fields: bool = ...,
|
||||
force_colon: bool = ...,
|
||||
*,
|
||||
# Same kwargs as MessageToString
|
||||
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,
|
||||
) -> bytes: ...
|
||||
def PrintMessage(
|
||||
message: Message,
|
||||
out: SupportsWrite[str],
|
||||
indent: int = 0,
|
||||
as_utf8: bool = False,
|
||||
as_utf8: bool = True,
|
||||
as_one_line: bool = False,
|
||||
use_short_repeated_primitives: bool = False,
|
||||
pointy_brackets: bool = False,
|
||||
@@ -78,7 +80,7 @@ def PrintField(
|
||||
value: Any,
|
||||
out: SupportsWrite[str],
|
||||
indent: int = 0,
|
||||
as_utf8: bool = False,
|
||||
as_utf8: bool = True,
|
||||
as_one_line: bool = False,
|
||||
use_short_repeated_primitives: bool = False,
|
||||
pointy_brackets: bool = False,
|
||||
@@ -94,7 +96,7 @@ def PrintFieldValue(
|
||||
value: Any,
|
||||
out: SupportsWrite[str],
|
||||
indent: int = 0,
|
||||
as_utf8: bool = False,
|
||||
as_utf8: bool = True,
|
||||
as_one_line: bool = False,
|
||||
use_short_repeated_primitives: bool = False,
|
||||
pointy_brackets: bool = False,
|
||||
@@ -125,7 +127,7 @@ class _Printer:
|
||||
self,
|
||||
out: SupportsWrite[str],
|
||||
indent: int = 0,
|
||||
as_utf8: bool = False,
|
||||
as_utf8: bool = True,
|
||||
as_one_line: bool = False,
|
||||
use_short_repeated_primitives: bool = False,
|
||||
pointy_brackets: bool = False,
|
||||
|
||||
Reference in New Issue
Block a user