Skip to content

Commit a850d8e

Browse files
committed
Update proto stubs with latest mypy-protobuf
1 parent 8d12d6f commit a850d8e

14 files changed

+1241
-1307
lines changed

scripts/generate_proto_stubs.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
# followed by committing the changes to typeshed
1010
#
1111
# Update these two variables when rerunning script
12-
PROTOBUF_VERSION=3.14.0
13-
MYPY_PROTOBUF_VERSION=v1.24
12+
PROTOBUF_VERSION=3.17.3
13+
MYPY_PROTOBUF_VERSION=v2.6
1414

1515
set -ex
1616

1717
if uname -a | grep Darwin; then
18+
# brew install coreutils wget
1819
PLAT=osx
1920
else
2021
PLAT=linux
@@ -43,10 +44,10 @@ PYTHON_PROTOBUF_DIR=protobuf-$PROTOBUF_VERSION
4344
VENV=venv
4445
python3 -m venv $VENV
4546
source $VENV/bin/activate
46-
pip install -r requirements-tests-py3.txt # for black and isort
47+
pip install -r $REPO_ROOT/requirements-tests-py3.txt # for black and isort
4748

4849
# Install mypy-protobuf
49-
pip install git+https://github.com/dropbox/mypy-protobuf@${MYPY_PROTOBUF_VERSION}#subdirectory=python
50+
pip install git+https://github.com/dropbox/mypy-protobuf@${MYPY_PROTOBUF_VERSION}
5051

5152
# Remove existing pyi
5253
find $REPO_ROOT/stubs/protobuf/ -name "*_pb2.pyi" -delete

stubs/protobuf/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version = "0.1"
1+
version = "0.2"
22
python2 = true
33
requires = ["types-futures"]

stubs/protobuf/google/protobuf/any_pb2.pyi

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,26 @@
22
@generated by mypy-protobuf. Do not edit manually!
33
isort:skip_file
44
"""
5-
from google.protobuf.descriptor import (
6-
Descriptor as google___protobuf___descriptor___Descriptor,
7-
FileDescriptor as google___protobuf___descriptor___FileDescriptor,
8-
)
9-
10-
from google.protobuf.internal.well_known_types import (
11-
Any as google___protobuf___internal___well_known_types___Any,
12-
)
13-
14-
from google.protobuf.message import (
15-
Message as google___protobuf___message___Message,
16-
)
17-
18-
from typing import (
19-
Optional as typing___Optional,
20-
Text as typing___Text,
21-
)
22-
23-
from typing_extensions import (
24-
Literal as typing_extensions___Literal,
25-
)
26-
27-
28-
builtin___bool = bool
29-
builtin___bytes = bytes
30-
builtin___float = float
31-
builtin___int = int
32-
33-
34-
DESCRIPTOR: google___protobuf___descriptor___FileDescriptor = ...
35-
36-
class Any(google___protobuf___message___Message, google___protobuf___internal___well_known_types___Any):
37-
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
38-
type_url: typing___Text = ...
39-
value: builtin___bytes = ...
5+
import builtins
6+
import google.protobuf.descriptor
7+
import google.protobuf.internal.well_known_types
8+
import google.protobuf.message
9+
import typing
10+
import typing_extensions
11+
12+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor = ...
13+
14+
class Any(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Any):
15+
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
16+
TYPE_URL_FIELD_NUMBER: builtins.int
17+
VALUE_FIELD_NUMBER: builtins.int
18+
type_url: typing.Text = ...
19+
value: builtins.bytes = ...
4020

4121
def __init__(self,
4222
*,
43-
type_url : typing___Optional[typing___Text] = ...,
44-
value : typing___Optional[builtin___bytes] = ...,
23+
type_url : typing.Text = ...,
24+
value : builtins.bytes = ...,
4525
) -> None: ...
46-
def ClearField(self, field_name: typing_extensions___Literal[u"type_url",b"type_url",u"value",b"value"]) -> None: ...
47-
type___Any = Any
26+
def ClearField(self, field_name: typing_extensions.Literal[u"type_url",b"type_url",u"value",b"value"]) -> None: ...
27+
global___Any = Any

stubs/protobuf/google/protobuf/api_pb2.pyi

Lines changed: 73 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,113 +2,99 @@
22
@generated by mypy-protobuf. Do not edit manually!
33
isort:skip_file
44
"""
5-
from google.protobuf.descriptor import (
6-
Descriptor as google___protobuf___descriptor___Descriptor,
7-
FileDescriptor as google___protobuf___descriptor___FileDescriptor,
8-
)
9-
10-
from google.protobuf.internal.containers import (
11-
RepeatedCompositeFieldContainer as google___protobuf___internal___containers___RepeatedCompositeFieldContainer,
12-
)
13-
14-
from google.protobuf.message import (
15-
Message as google___protobuf___message___Message,
16-
)
17-
18-
from google.protobuf.source_context_pb2 import (
19-
SourceContext as google___protobuf___source_context_pb2___SourceContext,
20-
)
21-
22-
from google.protobuf.type_pb2 import (
23-
Option as google___protobuf___type_pb2___Option,
24-
SyntaxValue as google___protobuf___type_pb2___SyntaxValue,
25-
)
26-
27-
from typing import (
28-
Iterable as typing___Iterable,
29-
Optional as typing___Optional,
30-
Text as typing___Text,
31-
)
32-
33-
from typing_extensions import (
34-
Literal as typing_extensions___Literal,
35-
)
36-
37-
38-
builtin___bool = bool
39-
builtin___bytes = bytes
40-
builtin___float = float
41-
builtin___int = int
42-
43-
44-
DESCRIPTOR: google___protobuf___descriptor___FileDescriptor = ...
45-
46-
class Api(google___protobuf___message___Message):
47-
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
48-
name: typing___Text = ...
49-
version: typing___Text = ...
50-
syntax: google___protobuf___type_pb2___SyntaxValue = ...
5+
import builtins
6+
import google.protobuf.descriptor
7+
import google.protobuf.internal.containers
8+
import google.protobuf.message
9+
import google.protobuf.source_context_pb2
10+
import google.protobuf.type_pb2
11+
import typing
12+
import typing_extensions
13+
14+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor = ...
15+
16+
class Api(google.protobuf.message.Message):
17+
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
18+
NAME_FIELD_NUMBER: builtins.int
19+
METHODS_FIELD_NUMBER: builtins.int
20+
OPTIONS_FIELD_NUMBER: builtins.int
21+
VERSION_FIELD_NUMBER: builtins.int
22+
SOURCE_CONTEXT_FIELD_NUMBER: builtins.int
23+
MIXINS_FIELD_NUMBER: builtins.int
24+
SYNTAX_FIELD_NUMBER: builtins.int
25+
name: typing.Text = ...
26+
version: typing.Text = ...
27+
syntax: google.protobuf.type_pb2.Syntax.V = ...
5128

5229
@property
53-
def methods(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___Method]: ...
30+
def methods(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Method]: ...
5431

5532
@property
56-
def options(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[google___protobuf___type_pb2___Option]: ...
33+
def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: ...
5734

5835
@property
59-
def source_context(self) -> google___protobuf___source_context_pb2___SourceContext: ...
36+
def source_context(self) -> google.protobuf.source_context_pb2.SourceContext: ...
6037

6138
@property
62-
def mixins(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___Mixin]: ...
39+
def mixins(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Mixin]: ...
6340

6441
def __init__(self,
6542
*,
66-
name : typing___Optional[typing___Text] = ...,
67-
methods : typing___Optional[typing___Iterable[type___Method]] = ...,
68-
options : typing___Optional[typing___Iterable[google___protobuf___type_pb2___Option]] = ...,
69-
version : typing___Optional[typing___Text] = ...,
70-
source_context : typing___Optional[google___protobuf___source_context_pb2___SourceContext] = ...,
71-
mixins : typing___Optional[typing___Iterable[type___Mixin]] = ...,
72-
syntax : typing___Optional[google___protobuf___type_pb2___SyntaxValue] = ...,
43+
name : typing.Text = ...,
44+
methods : typing.Optional[typing.Iterable[global___Method]] = ...,
45+
options : typing.Optional[typing.Iterable[google.protobuf.type_pb2.Option]] = ...,
46+
version : typing.Text = ...,
47+
source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ...,
48+
mixins : typing.Optional[typing.Iterable[global___Mixin]] = ...,
49+
syntax : google.protobuf.type_pb2.Syntax.V = ...,
7350
) -> None: ...
74-
def HasField(self, field_name: typing_extensions___Literal[u"source_context",b"source_context"]) -> builtin___bool: ...
75-
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: ...
76-
type___Api = Api
77-
78-
class Method(google___protobuf___message___Message):
79-
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
80-
name: typing___Text = ...
81-
request_type_url: typing___Text = ...
82-
request_streaming: builtin___bool = ...
83-
response_type_url: typing___Text = ...
84-
response_streaming: builtin___bool = ...
85-
syntax: google___protobuf___type_pb2___SyntaxValue = ...
51+
def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ...
52+
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: ...
53+
global___Api = Api
54+
55+
class Method(google.protobuf.message.Message):
56+
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
57+
NAME_FIELD_NUMBER: builtins.int
58+
REQUEST_TYPE_URL_FIELD_NUMBER: builtins.int
59+
REQUEST_STREAMING_FIELD_NUMBER: builtins.int
60+
RESPONSE_TYPE_URL_FIELD_NUMBER: builtins.int
61+
RESPONSE_STREAMING_FIELD_NUMBER: builtins.int
62+
OPTIONS_FIELD_NUMBER: builtins.int
63+
SYNTAX_FIELD_NUMBER: builtins.int
64+
name: typing.Text = ...
65+
request_type_url: typing.Text = ...
66+
request_streaming: builtins.bool = ...
67+
response_type_url: typing.Text = ...
68+
response_streaming: builtins.bool = ...
69+
syntax: google.protobuf.type_pb2.Syntax.V = ...
8670

8771
@property
88-
def options(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[google___protobuf___type_pb2___Option]: ...
72+
def options(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]: ...
8973

9074
def __init__(self,
9175
*,
92-
name : typing___Optional[typing___Text] = ...,
93-
request_type_url : typing___Optional[typing___Text] = ...,
94-
request_streaming : typing___Optional[builtin___bool] = ...,
95-
response_type_url : typing___Optional[typing___Text] = ...,
96-
response_streaming : typing___Optional[builtin___bool] = ...,
97-
options : typing___Optional[typing___Iterable[google___protobuf___type_pb2___Option]] = ...,
98-
syntax : typing___Optional[google___protobuf___type_pb2___SyntaxValue] = ...,
76+
name : typing.Text = ...,
77+
request_type_url : typing.Text = ...,
78+
request_streaming : builtins.bool = ...,
79+
response_type_url : typing.Text = ...,
80+
response_streaming : builtins.bool = ...,
81+
options : typing.Optional[typing.Iterable[google.protobuf.type_pb2.Option]] = ...,
82+
syntax : google.protobuf.type_pb2.Syntax.V = ...,
9983
) -> None: ...
100-
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: ...
101-
type___Method = Method
84+
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: ...
85+
global___Method = Method
10286

103-
class Mixin(google___protobuf___message___Message):
104-
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
105-
name: typing___Text = ...
106-
root: typing___Text = ...
87+
class Mixin(google.protobuf.message.Message):
88+
DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
89+
NAME_FIELD_NUMBER: builtins.int
90+
ROOT_FIELD_NUMBER: builtins.int
91+
name: typing.Text = ...
92+
root: typing.Text = ...
10793

10894
def __init__(self,
10995
*,
110-
name : typing___Optional[typing___Text] = ...,
111-
root : typing___Optional[typing___Text] = ...,
96+
name : typing.Text = ...,
97+
root : typing.Text = ...,
11298
) -> None: ...
113-
def ClearField(self, field_name: typing_extensions___Literal[u"name",b"name",u"root",b"root"]) -> None: ...
114-
type___Mixin = Mixin
99+
def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"root",b"root"]) -> None: ...
100+
global___Mixin = Mixin

0 commit comments

Comments
 (0)