Skip to content

Update protobuf generated stubs from mypy-protobuf 2.8 #5804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/generate_proto_stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# Update these two variables when rerunning script
PROTOBUF_VERSION=3.17.3
MYPY_PROTOBUF_VERSION=v2.6
MYPY_PROTOBUF_VERSION=v2.8

set -ex

Expand Down Expand Up @@ -73,3 +73,5 @@ protoc_install/bin/protoc --proto_path=$PYTHON_PROTOBUF_DIR/src --mypy_out=$REPO

isort $REPO_ROOT/stubs/protobuf
black $REPO_ROOT/stubs/protobuf

sed -i="" "s/mypy-protobuf [^\"]*/mypy-protobuf ${MYPY_PROTOBUF_VERSION}/" $REPO_ROOT/stubs/protobuf/METADATA.toml
9 changes: 9 additions & 0 deletions stubs/protobuf/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse.FEATURE_PROTO3_OPTIONA
google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse.Feature
google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse.File.__init__
google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse._Feature
google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse._FeatureEnumTypeWrapper
google.protobuf.compiler.plugin_pb2.CodeGeneratorResponse.__init__
google.protobuf.compiler.plugin_pb2.Version.__init__
google.protobuf.descriptor.Descriptor.__new__
Expand Down Expand Up @@ -49,7 +50,9 @@ google.protobuf.descriptor_pb2.FieldDescriptorProto.TYPE_UINT32
google.protobuf.descriptor_pb2.FieldDescriptorProto.TYPE_UINT64
google.protobuf.descriptor_pb2.FieldDescriptorProto.Type
google.protobuf.descriptor_pb2.FieldDescriptorProto._Label
google.protobuf.descriptor_pb2.FieldDescriptorProto._LabelEnumTypeWrapper
google.protobuf.descriptor_pb2.FieldDescriptorProto._Type
google.protobuf.descriptor_pb2.FieldDescriptorProto._TypeEnumTypeWrapper
google.protobuf.descriptor_pb2.FieldDescriptorProto.__init__
google.protobuf.descriptor_pb2.FieldOptions.CORD
google.protobuf.descriptor_pb2.FieldOptions.CType
Expand All @@ -60,7 +63,9 @@ google.protobuf.descriptor_pb2.FieldOptions.JS_STRING
google.protobuf.descriptor_pb2.FieldOptions.STRING
google.protobuf.descriptor_pb2.FieldOptions.STRING_PIECE
google.protobuf.descriptor_pb2.FieldOptions._CType
google.protobuf.descriptor_pb2.FieldOptions._CTypeEnumTypeWrapper
google.protobuf.descriptor_pb2.FieldOptions._JSType
google.protobuf.descriptor_pb2.FieldOptions._JSTypeEnumTypeWrapper
google.protobuf.descriptor_pb2.FieldOptions.__init__
google.protobuf.descriptor_pb2.FileDescriptorProto.__init__
google.protobuf.descriptor_pb2.FileDescriptorSet.__init__
Expand All @@ -69,6 +74,7 @@ google.protobuf.descriptor_pb2.FileOptions.LITE_RUNTIME
google.protobuf.descriptor_pb2.FileOptions.OptimizeMode
google.protobuf.descriptor_pb2.FileOptions.SPEED
google.protobuf.descriptor_pb2.FileOptions._OptimizeMode
google.protobuf.descriptor_pb2.FileOptions._OptimizeModeEnumTypeWrapper
google.protobuf.descriptor_pb2.FileOptions.__init__
google.protobuf.descriptor_pb2.GeneratedCodeInfo.Annotation.__init__
google.protobuf.descriptor_pb2.GeneratedCodeInfo.__init__
Expand All @@ -79,6 +85,7 @@ google.protobuf.descriptor_pb2.MethodOptions.IDEMPOTENT
google.protobuf.descriptor_pb2.MethodOptions.IdempotencyLevel
google.protobuf.descriptor_pb2.MethodOptions.NO_SIDE_EFFECTS
google.protobuf.descriptor_pb2.MethodOptions._IdempotencyLevel
google.protobuf.descriptor_pb2.MethodOptions._IdempotencyLevelEnumTypeWrapper
google.protobuf.descriptor_pb2.MethodOptions.__init__
google.protobuf.descriptor_pb2.OneofDescriptorProto.__init__
google.protobuf.descriptor_pb2.OneofOptions.__init__
Expand Down Expand Up @@ -154,7 +161,9 @@ google.protobuf.type_pb2.Field.TYPE_UINT32
google.protobuf.type_pb2.Field.TYPE_UINT64
google.protobuf.type_pb2.Field.TYPE_UNKNOWN
google.protobuf.type_pb2.Field._Cardinality
google.protobuf.type_pb2.Field._CardinalityEnumTypeWrapper
google.protobuf.type_pb2.Field._Kind
google.protobuf.type_pb2.Field._KindEnumTypeWrapper
google.protobuf.type_pb2.Field.__init__
google.protobuf.type_pb2.Option.__init__
google.protobuf.type_pb2.SYNTAX_PROTO2
Expand Down
2 changes: 1 addition & 1 deletion stubs/protobuf/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.17"
python2 = true
requires = ["types-futures"]
extra_description = "Generated with aid from mypy-protobuf 2.6"
extra_description = "Generated with aid from mypy-protobuf v2.8"
111 changes: 110 additions & 1 deletion stubs/protobuf/google/protobuf/any_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,122 @@ import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor = ...

# `Any` contains an arbitrary serialized protocol buffer message along with a
# URL that describes the type of the serialized message.
#
# Protobuf library provides support to pack/unpack Any values in the form
# of utility functions or additional generated methods of the Any type.
#
# Example 1: Pack and unpack a message in C++.
#
# Foo foo = ...;
# Any any;
# any.PackFrom(foo);
# ...
# if (any.UnpackTo(&foo)) {
# ...
# }
#
# Example 2: Pack and unpack a message in Java.
#
# Foo foo = ...;
# Any any = Any.pack(foo);
# ...
# if (any.is(Foo.class)) {
# foo = any.unpack(Foo.class);
# }
#
# Example 3: Pack and unpack a message in Python.
#
# foo = Foo(...)
# any = Any()
# any.Pack(foo)
# ...
# if any.Is(Foo.DESCRIPTOR):
# any.Unpack(foo)
# ...
#
# Example 4: Pack and unpack a message in Go
#
# foo := &pb.Foo{...}
# any, err := anypb.New(foo)
# if err != nil {
# ...
# }
# ...
# foo := &pb.Foo{}
# if err := any.UnmarshalTo(foo); err != nil {
# ...
# }
#
# The pack methods provided by protobuf library will by default use
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
# methods only use the fully qualified type name after the last '/'
# 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
# representation of the deserialized, embedded message, with an
# additional field `@type` which contains the type URL. Example:
#
# package google.profile;
# message Person {
# string first_name = 1;
# string last_name = 2;
# }
#
# {
# "@type": "type.googleapis.com/google.profile.Person",
# "firstName": <string>,
# "lastName": <string>
# }
#
# If the embedded message type is well-known and has a custom JSON
# representation, that representation will be embedded adding a field
# `value` which holds the custom JSON in addition to the `@type`
# field. Example (for message [google.protobuf.Duration][]):
#
# {
# "@type": "type.googleapis.com/google.protobuf.Duration",
# "value": "1.212s"
# }
class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Any):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
TYPE_URL_FIELD_NUMBER: builtins.int
VALUE_FIELD_NUMBER: builtins.int
# A URL/resource name that uniquely identifies the type of the serialized
# protocol buffer message. This string must contain at least
# one "/" character. The last segment of the URL's path must represent
# the fully qualified name of the type (as in
# `path/google.protobuf.Duration`). The name should be in a canonical form
# (e.g., leading "." is not accepted).
#
# In practice, teams usually precompile into the binary all types that they
# expect it to use in the context of Any. However, for URLs which use the
# scheme `http`, `https`, or no scheme, one can optionally set up a type
# server that maps type URLs to message definitions as follows:
#
# * If no scheme is provided, `https` is assumed.
# * An HTTP GET on the URL must yield a [google.protobuf.Type][]
# value in binary format, or produce an error.
# * Applications are allowed to cache lookup results based on the
# URL, or have them precompiled into a binary to avoid any
# lookup. Therefore, binary compatibility needs to be preserved
# on changes to types. (Use versioned type names to manage
# breaking changes.)
#
# 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.
#
# Schemes other than `http`, `https` (or the empty scheme) might be
# used with implementation specific semantics.
type_url: typing.Text = ...
# Must be a valid serialized protocol buffer of the above specified type.
value: builtins.bytes = ...

def __init__(self,
*,
type_url : typing.Text = ...,
Expand Down
139 changes: 128 additions & 11 deletions stubs/protobuf/google/protobuf/api_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor = ...

# Api is a light-weight descriptor for an API Interface.
#
# Interfaces are also described as "protocol buffer services" in some contexts,
# such as by the "service" keyword in a .proto file, but they are different
# from API Services, which represent a concrete implementation of an interface
# as opposed to simply a description of methods and bindings. They are also
# sometimes simply referred to as "APIs" in other contexts, such as the name of
# this message itself. See https://cloud.google.com/apis/design/glossary for
# detailed terminology.
class Api(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
NAME_FIELD_NUMBER: builtins.int
Expand All @@ -22,22 +31,44 @@ class Api(google.protobuf.message.Message):
SOURCE_CONTEXT_FIELD_NUMBER: builtins.int
MIXINS_FIELD_NUMBER: builtins.int
SYNTAX_FIELD_NUMBER: builtins.int
# The fully qualified name of this interface, including package name
# followed by the interface's simple name.
name: typing.Text = ...
version: typing.Text = ...
syntax: google.protobuf.type_pb2.Syntax.V = ...

# The methods of this interface, in unspecified order.
@property
def methods(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Method]: ...

# Any metadata attached to the interface.
@property
def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: ...

# 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
# omitted, it defaults to zero. If the entire version field is empty, the
# major version is derived from the package name, as outlined below. If the
# field is not empty, the version in the package name will be verified to be
# consistent with what is provided here.
#
# The versioning schema uses [semantic
# versioning](http://semver.org) where the major version number
# indicates a breaking change and the minor version an additive,
# non-breaking change. Both version numbers are signals to users
# what to expect from different versions, and should be carefully
# chosen based on the product plan.
#
# The major version is also reflected in the package name of the
# interface, which must end in `v<major-version>`, as in
# `google.feature.v1`. For major versions 0 and 1, the suffix can
# be omitted. Zero major versions must only be used for
# experimental, non-GA interfaces.
version: typing.Text = ...
# Source context for the protocol buffer service represented by this
# message.
@property
def source_context(self) -> google.protobuf.source_context_pb2.SourceContext: ...

# Included interfaces. See [Mixin][].
@property
def mixins(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Mixin]: ...

# The source syntax of the service.
syntax: google.protobuf.type_pb2.Syntax.V = ...
def __init__(self,
*,
name : typing.Text = ...,
Expand All @@ -52,6 +83,7 @@ class Api(google.protobuf.message.Message):
def ClearField(self, field_name: typing_extensions.Literal[u"methods",b"methods",u"mixins",b"mixins",u"name",b"name",u"options",b"options",u"source_context",b"source_context",u"syntax",b"syntax",u"version",b"version"]) -> None: ...
global___Api = Api

# Method represents a method of an API interface.
class Method(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
NAME_FIELD_NUMBER: builtins.int
Expand All @@ -61,16 +93,21 @@ class Method(google.protobuf.message.Message):
RESPONSE_STREAMING_FIELD_NUMBER: builtins.int
OPTIONS_FIELD_NUMBER: builtins.int
SYNTAX_FIELD_NUMBER: builtins.int
# The simple name of this method.
name: typing.Text = ...
# A URL of the input message type.
request_type_url: typing.Text = ...
# If true, the request is streamed.
request_streaming: builtins.bool = ...
# The URL of the output message type.
response_type_url: typing.Text = ...
# If true, the response is streamed.
response_streaming: builtins.bool = ...
syntax: google.protobuf.type_pb2.Syntax.V = ...

# Any metadata attached to the method.
@property
def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: ...

# The source syntax of this method.
syntax: google.protobuf.type_pb2.Syntax.V = ...
def __init__(self,
*,
name : typing.Text = ...,
Expand All @@ -84,13 +121,93 @@ class Method(google.protobuf.message.Message):
def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"request_streaming",b"request_streaming",u"request_type_url",b"request_type_url",u"response_streaming",b"response_streaming",u"response_type_url",b"response_type_url",u"syntax",b"syntax"]) -> None: ...
global___Method = Method

# Declares an API Interface to be included in this interface. The including
# interface must redeclare all the methods from the included interface, but
# documentation and options are inherited as follows:
#
# - If after comment and whitespace stripping, the documentation
# string of the redeclared method is empty, it will be inherited
# from the original method.
#
# - Each annotation belonging to the service config (http,
# visibility) which is not set in the redeclared method will be
# inherited.
#
# - If an http annotation is inherited, the path pattern will be
# modified as follows. Any version prefix will be replaced by the
# version of the including interface plus the [root][] path if
# specified.
#
# Example of a simple mixin:
#
# package google.acl.v1;
# service AccessControl {
# // Get the underlying ACL object.
# rpc GetAcl(GetAclRequest) returns (Acl) {
# option (google.api.http).get = "/v1/{resource=**}:getAcl";
# }
# }
#
# package google.storage.v2;
# service Storage {
# rpc GetAcl(GetAclRequest) returns (Acl);
#
# // Get a data record.
# rpc GetData(GetDataRequest) returns (Data) {
# option (google.api.http).get = "/v2/{resource=**}";
# }
# }
#
# Example of a mixin configuration:
#
# apis:
# - name: google.storage.v2.Storage
# mixins:
# - name: google.acl.v1.AccessControl
#
# 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
# documentation and annotations as follows:
#
# service Storage {
# // Get the underlying ACL object.
# rpc GetAcl(GetAclRequest) returns (Acl) {
# option (google.api.http).get = "/v2/{resource=**}:getAcl";
# }
# ...
# }
#
# Note how the version in the path pattern changed from `v1` to `v2`.
#
# If the `root` field in the mixin is specified, it should be a
# relative path under which inherited HTTP paths are placed. Example:
#
# apis:
# - name: google.storage.v2.Storage
# mixins:
# - name: google.acl.v1.AccessControl
# root: acls
#
# This implies the following inherited HTTP annotation:
#
# service Storage {
# // Get the underlying ACL object.
# rpc GetAcl(GetAclRequest) returns (Acl) {
# option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
# }
# ...
# }
class Mixin(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
NAME_FIELD_NUMBER: builtins.int
ROOT_FIELD_NUMBER: builtins.int
# The fully qualified name of the interface which is included.
name: typing.Text = ...
# If non-empty specifies a path under which inherited HTTP paths
# are rooted.
root: typing.Text = ...

def __init__(self,
*,
name : typing.Text = ...,
Expand Down
Loading