-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathtest.proto
More file actions
218 lines (183 loc) · 5.23 KB
/
test.proto
File metadata and controls
218 lines (183 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// Proto 2 test file.
syntax = "proto2";
package test;
import "google/protobuf/empty.proto";
import "mypy_protobuf/extensions.proto";
import "testproto/inner/inner.proto";
import "testproto/inner/test3.proto";
import "testproto/nested/nested.proto";
import "testproto/nopackage.proto";
import "testproto/test3.proto";
// Outer Enum
enum OuterEnum {
// FOO
FOO = 1;
// BAR
BAR = 2;
}
// Naming conflicts!
enum NamingConflicts {
Name = 1;
Value = 2;
keys = 3;
values = 4;
items = 5;
// See https://github.com/protocolbuffers/protobuf/issues/8803
// proto itself generates broken code when DESCRIPTOR is there
// DESCRIPTOR = 8;
}
// Message with one of everything
message Simple1 {
// Inner Enum
enum InnerEnum {
// INNER1
INNER1 = 1;
// INNER2
INNER2 = 2;
}
message InnerMessage {}
optional string a_string = 1;
repeated string a_repeated_string = 2;
optional bool a_boolean = 3;
optional uint32 a_uint32 = 4;
optional OuterEnum a_enum = 5;
optional test3.OuterEnum a_external_enum = 6;
optional inner.Inner a_inner = 7;
optional test.nested_package.Nested a_nested = 12;
optional InnerEnum inner_enum = 8;
repeated InnerEnum rep_inner_enum = 9;
optional InnerMessage inner_message = 10;
repeated InnerMessage rep_inner_message = 11;
optional NoPackage no_package = 13;
optional test.nested_package.AnotherNested.NestedEnum nested_enum = 14;
optional test.nested_package.AnotherNested.NestedMessage nested_message = 15;
oneof a_oneof {
string a_oneof_1 = 16;
string a_oneof_2 = 17;
Simple2 outer_message_in_oneof = 18;
OuterEnum outer_enum_in_oneof = 19;
InnerEnum inner_enum_in_oneof = 20;
}
optional uint32 user_id = 21 [(mypy_protobuf.casttype)="test/test_generated_mypy.UserId"];
optional string email = 22 [(mypy_protobuf.casttype)="test/test_generated_mypy.Email"];
map<uint32, string> email_by_uid = 23 [
(mypy_protobuf.keytype)="test/test_generated_mypy.UserId",
(mypy_protobuf.valuetype)="test/test_generated_mypy.Email"
];
optional string property = 24;
optional string collections = 25;
optional string testproto = 26;
optional .google.protobuf.Empty empty = 27;
optional string sys = 28;
extensions 1000 to max;
}
message Simple2 {
required string a_string = 1;
extensions 1000 to max;
}
message Extensions1 {
extend Simple1 {
// ext
optional Extensions1 ext = 1000;
}
optional string ext1_string = 1;
}
message Extensions2 {
extend Simple1 {
// foo
optional Extensions2 foo = 2020;
}
optional bool flag = 1;
}
message None {
optional int64 valid = 1;
}
message PythonReservedKeywords {
enum finally {
continue = 1;
valid_in_finally = 2;
}
message lambda {
optional int64 continue = 1;
optional int64 valid = 2;
}
required int64 from = 1;
optional Simple2 in = 2;
optional finally is = 3;
optional int64 for = 5;
optional int64 try = 6;
optional int64 def = 7;
optional int64 nonlocal = 8;
optional int64 while = 9;
optional int64 and = 10;
optional int64 del = 11;
optional int64 global = 12;
optional int64 not = 13;
optional int64 with = 14;
optional int64 as = 15;
optional int64 elif = 16;
optional int64 if = 17;
optional int64 or = 18;
optional int64 yield = 19;
optional int64 assert = 20;
optional int64 else = 21;
optional int64 import = 22;
optional int64 pass = 23;
optional int64 break = 24;
optional int64 except = 25;
optional int64 raise = 26;
optional int64 False = 27;
optional int64 True = 29;
optional int64 class = 30;
// Test unreserved identifiers w/ reserved message names
optional None none = 28;
optional finally valid = 31;
}
// Do one with just one arg - to make sure it's syntactically correct
message PythonReservedKeywordsSmall {
required int64 from = 1;
}
// Method name is reserved
service PythonReservedKeywordsService {
// lambda
rpc lambda(Simple1) returns (PythonReservedKeywords.lambda) {}
// valid_method_name1
rpc valid_method_name1(Simple1) returns (None) {}
// valid_method_name2
rpc valid_method_name2(Simple1) returns (PythonReservedKeywords.lambda) {}
}
message SelfField {
// Field self -> must generate an __init__ method w/ different name
optional int64 self = 1;
}
message DeprecatedMessage {
// This message is deprecated
option deprecated = true;
optional string a_string = 1;
optional string deprecated_field = 2 [deprecated = true];
// This field is deprecated with comment
optional string deprecated_field_with_comment = 3 [deprecated = true];
}
message DeprecatedMessageBadComment {
// This message is deprecated
// """ triple quotes in comment
option deprecated = true;
optional string a_string = 1;
}
enum DeprecatedEnum {
// This enum is deprecated
// 2 lines of comments
// "Quotes in comments"
// and 'single quotes'
option deprecated = true;
// Trailing comment
DEPRECATED_ONE = 1 [
// This enum value is deprecated but this message doesn't show
deprecated = true
]; // Trailing comment for enum value
DEPRECATED_TWO = 2 [deprecated = true];
NOT_DEPRECATED = 3;
}
message TestDuplicatePackageMessage {
required inner.DuplicatePackageMessage msg = 1;
}