Skip to content

Commit e59fa45

Browse files
authored
pass -> Ellipsis, typing.Text -> str (#380)
1 parent 137abc9 commit e59fa45

14 files changed

+104
-111
lines changed

mypy_protobuf/extensions_pb2.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ import builtins
66
import google.protobuf.descriptor
77
import google.protobuf.descriptor_pb2
88
import google.protobuf.internal.extension_dict
9-
import typing
109

1110
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1211

1312
CASTTYPE_FIELD_NUMBER: builtins.int
1413
KEYTYPE_FIELD_NUMBER: builtins.int
1514
VALUETYPE_FIELD_NUMBER: builtins.int
16-
casttype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, typing.Text]
15+
casttype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
1716
"""Tells mypy to use a specific newtype rather than the normal type for this field."""
1817

19-
keytype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, typing.Text]
18+
keytype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
2019
"""Tells mypy to use a specific type for keys; only makes sense on map fields"""
2120

22-
valuetype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, typing.Text]
21+
valuetype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
2322
"""Tells mypy to use a specific type for values; only makes sense on map fields"""

mypy_protobuf/main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def write_enums(
364364
l(f"class {class_name}({enum_helper_class}, metaclass={etw_helper_class}):")
365365
with self._indent():
366366
self._write_comments(scl)
367-
l("pass")
367+
l("...")
368368
l("")
369369

370370
self.write_enum_values(
@@ -453,7 +453,7 @@ def write_messages(
453453
if self._has_comments(scl_field):
454454
with self._indent():
455455
self._write_comments(scl_field)
456-
l("pass")
456+
l("...")
457457

458458
self.write_extensions(
459459
desc.extension, scl + [d.DescriptorProto.EXTENSION_FIELD_NUMBER]
@@ -603,7 +603,7 @@ def write_methods(
603603
if m.name not in PYTHON_RESERVED
604604
]
605605
if not methods:
606-
l("pass")
606+
l("...")
607607
for i, method in methods:
608608
if is_abstract:
609609
l("@{}", self._import("abc", "abstractmethod"))
@@ -632,7 +632,7 @@ def write_methods(
632632
if self._has_comments(scl_method):
633633
with self._indent():
634634
self._write_comments(scl_method)
635-
l("pass")
635+
l("...")
636636

637637
def write_services(
638638
self,
@@ -739,7 +739,7 @@ def write_grpc_methods(
739739
if m.name not in PYTHON_RESERVED
740740
]
741741
if not methods:
742-
l("pass")
742+
l("...")
743743
l("")
744744
for i, method in methods:
745745
scl = scl_prefix + [d.ServiceDescriptorProto.METHOD_FIELD_NUMBER, i]
@@ -761,7 +761,7 @@ def write_grpc_methods(
761761
if self._has_comments(scl):
762762
with self._indent():
763763
self._write_comments(scl)
764-
l("pass")
764+
l("...")
765765
l("")
766766

767767
def write_grpc_stub_methods(
@@ -774,7 +774,7 @@ def write_grpc_stub_methods(
774774
if m.name not in PYTHON_RESERVED
775775
]
776776
if not methods:
777-
l("pass")
777+
l("...")
778778
l("")
779779
for i, method in methods:
780780
scl = scl_prefix + [d.ServiceDescriptorProto.METHOD_FIELD_NUMBER, i]
@@ -855,7 +855,7 @@ def python_type(
855855
d.FieldDescriptorProto.TYPE_SFIXED32: lambda: self._builtin("int"),
856856
d.FieldDescriptorProto.TYPE_SINT32: lambda: self._builtin("int"),
857857
d.FieldDescriptorProto.TYPE_BOOL: lambda: self._builtin("bool"),
858-
d.FieldDescriptorProto.TYPE_STRING: lambda: self._import("typing", "Text"),
858+
d.FieldDescriptorProto.TYPE_STRING: lambda: self._builtin("str"),
859859
d.FieldDescriptorProto.TYPE_BYTES: lambda: self._builtin("bytes"),
860860
d.FieldDescriptorProto.TYPE_ENUM: lambda: self._import_message(
861861
field.type_name + ".ValueType"

test/generated/mypy_protobuf/extensions_pb2.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ import builtins
66
import google.protobuf.descriptor
77
import google.protobuf.descriptor_pb2
88
import google.protobuf.internal.extension_dict
9-
import typing
109

1110
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1211

1312
CASTTYPE_FIELD_NUMBER: builtins.int
1413
KEYTYPE_FIELD_NUMBER: builtins.int
1514
VALUETYPE_FIELD_NUMBER: builtins.int
16-
casttype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, typing.Text]
15+
casttype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
1716
"""Tells mypy to use a specific newtype rather than the normal type for this field."""
1817

19-
keytype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, typing.Text]
18+
keytype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
2019
"""Tells mypy to use a specific type for keys; only makes sense on map fields"""
2120

22-
valuetype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, typing.Text]
21+
valuetype: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
2322
"""Tells mypy to use a specific type for values; only makes sense on map fields"""

test/generated/testproto/comment_special_chars_pb2.pyi

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ isort:skip_file
55
import builtins
66
import google.protobuf.descriptor
77
import google.protobuf.message
8-
import typing
98
import typing_extensions
109

1110
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
@@ -23,39 +22,39 @@ class Test(google.protobuf.message.Message):
2322
I_FIELD_NUMBER: builtins.int
2423
J_FIELD_NUMBER: builtins.int
2524
K_FIELD_NUMBER: builtins.int
26-
a: typing.Text
25+
a: builtins.str
2726
"""Ending with " """
2827

29-
b: typing.Text
28+
b: builtins.str
3029
"""Ending with "" """
3130

32-
c: typing.Text
31+
c: builtins.str
3332
"""Ending with \"\"\" """
3433

35-
d: typing.Text
34+
d: builtins.str
3635
"""Ending with \\ """
3736

38-
e: typing.Text
37+
e: builtins.str
3938
"""Containing bad escape: \\x"""
4039

41-
f: typing.Text
40+
f: builtins.str
4241
"""Containing \"\"\"" quadruple"""
4342

44-
g: typing.Text
43+
g: builtins.str
4544
"""Containing \"\"\""" quintuple"""
4645

47-
h: typing.Text
46+
h: builtins.str
4847
"""Containing \"\"\"\"\"\" sextuple"""
4948

50-
i: typing.Text
49+
i: builtins.str
5150
"""\"\"\" Multiple \"\"\" triples \"\"\" """
5251

53-
j: typing.Text
52+
j: builtins.str
5453
""""quotes" can be a problem in comments.
5554
\"\"\"Triple quotes\"\"\" just as well
5655
"""
5756

58-
k: typing.Text
57+
k: builtins.str
5958
"""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"
6059
" "
6160
" Super Duper comments with surrounding edges! "
@@ -67,17 +66,17 @@ class Test(google.protobuf.message.Message):
6766

6867
def __init__(self,
6968
*,
70-
a: typing.Text = ...,
71-
b: typing.Text = ...,
72-
c: typing.Text = ...,
73-
d: typing.Text = ...,
74-
e: typing.Text = ...,
75-
f: typing.Text = ...,
76-
g: typing.Text = ...,
77-
h: typing.Text = ...,
78-
i: typing.Text = ...,
79-
j: typing.Text = ...,
80-
k: typing.Text = ...,
69+
a: builtins.str = ...,
70+
b: builtins.str = ...,
71+
c: builtins.str = ...,
72+
d: builtins.str = ...,
73+
e: builtins.str = ...,
74+
f: builtins.str = ...,
75+
g: builtins.str = ...,
76+
h: builtins.str = ...,
77+
i: builtins.str = ...,
78+
j: builtins.str = ...,
79+
k: builtins.str = ...,
8180
) -> None: ...
8281
def ClearField(self, field_name: typing_extensions.Literal["a",b"a","b",b"b","c",b"c","d",b"d","e",b"e","f",b"f","g",b"g","h",b"h","i",b"i","j",b"j","k",b"k"]) -> None: ...
8382
global___Test = Test

test/generated/testproto/dot/com/test_pb2.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ isort:skip_file
55
import builtins
66
import google.protobuf.descriptor
77
import google.protobuf.message
8-
import typing
98
import typing_extensions
109

1110
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1211

1312
class TestMessage(google.protobuf.message.Message):
1413
DESCRIPTOR: google.protobuf.descriptor.Descriptor
1514
FOO_FIELD_NUMBER: builtins.int
16-
foo: typing.Text
15+
foo: builtins.str
1716
def __init__(self,
1817
*,
19-
foo: typing.Text = ...,
18+
foo: builtins.str = ...,
2019
) -> None: ...
2120
def ClearField(self, field_name: typing_extensions.Literal["foo",b"foo"]) -> None: ...
2221
global___TestMessage = TestMessage

test/generated/testproto/grpc/dummy_pb2.pyi

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@ isort:skip_file
55
import builtins
66
import google.protobuf.descriptor
77
import google.protobuf.message
8-
import typing
98
import typing_extensions
109

1110
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1211

1312
class DummyRequest(google.protobuf.message.Message):
1413
DESCRIPTOR: google.protobuf.descriptor.Descriptor
1514
VALUE_FIELD_NUMBER: builtins.int
16-
value: typing.Text
15+
value: builtins.str
1716
def __init__(self,
1817
*,
19-
value: typing.Text = ...,
18+
value: builtins.str = ...,
2019
) -> None: ...
2120
def ClearField(self, field_name: typing_extensions.Literal["value",b"value"]) -> None: ...
2221
global___DummyRequest = DummyRequest
2322

2423
class DummyReply(google.protobuf.message.Message):
2524
DESCRIPTOR: google.protobuf.descriptor.Descriptor
2625
VALUE_FIELD_NUMBER: builtins.int
27-
value: typing.Text
26+
value: builtins.str
2827
def __init__(self,
2928
*,
30-
value: typing.Text = ...,
29+
value: builtins.str = ...,
3130
) -> None: ...
3231
def ClearField(self, field_name: typing_extensions.Literal["value",b"value"]) -> None: ...
3332
global___DummyReply = DummyReply

test/generated/testproto/grpc/dummy_pb2_grpc.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ class DummyServiceServicer(metaclass=abc.ABCMeta):
3939
context: grpc.ServicerContext,
4040
) -> testproto.grpc.dummy_pb2.DummyReply:
4141
"""UnaryUnary"""
42-
pass
42+
...
4343

4444
@abc.abstractmethod
4545
def UnaryStream(self,
4646
request: testproto.grpc.dummy_pb2.DummyRequest,
4747
context: grpc.ServicerContext,
4848
) -> typing.Iterator[testproto.grpc.dummy_pb2.DummyReply]:
4949
"""UnaryStream"""
50-
pass
50+
...
5151

5252
@abc.abstractmethod
5353
def StreamUnary(self,
5454
request_iterator: typing.Iterator[testproto.grpc.dummy_pb2.DummyRequest],
5555
context: grpc.ServicerContext,
5656
) -> testproto.grpc.dummy_pb2.DummyReply:
5757
"""StreamUnary"""
58-
pass
58+
...
5959

6060
@abc.abstractmethod
6161
def StreamStream(self,
6262
request_iterator: typing.Iterator[testproto.grpc.dummy_pb2.DummyRequest],
6363
context: grpc.ServicerContext,
6464
) -> typing.Iterator[testproto.grpc.dummy_pb2.DummyReply]:
6565
"""StreamStream"""
66-
pass
66+
...
6767

6868

6969
def add_DummyServiceServicer_to_server(servicer: DummyServiceServicer, server: grpc.Server) -> None: ...

test/generated/testproto/grpc/import_pb2_grpc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta):
3333
context: grpc.ServicerContext,
3434
) -> testproto.test_pb2.Simple1:
3535
"""UnaryUnary"""
36-
pass
36+
...
3737

3838
@abc.abstractmethod
3939
def UnaryStream(self,
4040
request: testproto.test_pb2.Simple1,
4141
context: grpc.ServicerContext,
4242
) -> google.protobuf.empty_pb2.Empty:
4343
"""UnaryStream"""
44-
pass
44+
...
4545

4646
@abc.abstractmethod
4747
def NoComment(self,

test/generated/testproto/nested/nested_pb2.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AnotherNested(google.protobuf.message.Message):
3434
ONE: AnotherNested._NestedEnum.ValueType # 1
3535
TWO: AnotherNested._NestedEnum.ValueType # 2
3636
class NestedEnum(_NestedEnum, metaclass=_NestedEnumEnumTypeWrapper):
37-
pass
37+
...
3838

3939
INVALID: AnotherNested.NestedEnum.ValueType # 0
4040
ONE: AnotherNested.NestedEnum.ValueType # 1
@@ -51,7 +51,7 @@ class AnotherNested(google.protobuf.message.Message):
5151
NESTED_ENUM1: AnotherNested.NestedMessage._NestedEnum2.ValueType # 1
5252
NESTED_ENUM2: AnotherNested.NestedMessage._NestedEnum2.ValueType # 2
5353
class NestedEnum2(_NestedEnum2, metaclass=_NestedEnum2EnumTypeWrapper):
54-
pass
54+
...
5555

5656
UNDEFINED: AnotherNested.NestedMessage.NestedEnum2.ValueType # 0
5757
NESTED_ENUM1: AnotherNested.NestedMessage.NestedEnum2.ValueType # 1
@@ -61,13 +61,13 @@ class AnotherNested(google.protobuf.message.Message):
6161
B_FIELD_NUMBER: builtins.int
6262
NE_FIELD_NUMBER: builtins.int
6363
NE2_FIELD_NUMBER: builtins.int
64-
s: typing.Text
64+
s: builtins.str
6565
b: builtins.bool
6666
ne: global___AnotherNested.NestedEnum.ValueType
6767
ne2: global___AnotherNested.NestedMessage.NestedEnum2.ValueType
6868
def __init__(self,
6969
*,
70-
s: typing.Text = ...,
70+
s: builtins.str = ...,
7171
b: builtins.bool = ...,
7272
ne: global___AnotherNested.NestedEnum.ValueType = ...,
7373
ne2: global___AnotherNested.NestedMessage.NestedEnum2.ValueType = ...,

test/generated/testproto/readme_enum_pb2.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class _MyEnumEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTyp
1818
HELLO: _MyEnum.ValueType # 0
1919
WORLD: _MyEnum.ValueType # 1
2020
class MyEnum(_MyEnum, metaclass=_MyEnumEnumTypeWrapper):
21-
pass
21+
...
2222

2323
HELLO: MyEnum.ValueType # 0
2424
WORLD: MyEnum.ValueType # 1

0 commit comments

Comments
 (0)