Skip to content

Commit ac03ec7

Browse files
authored
Merge pull request #90 from so1n/89-refers-to-an-ungenerated-message-in-the-map
Fix, refers to an ungenerated message in the map type
2 parents f0ed025 + 8b510c7 commit ac03ec7

File tree

79 files changed

+940
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+940
-265
lines changed

example/example_proto/demo/demo.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,15 @@ message TestSameName1 {
159159
}
160160
Body body = 1;
161161
}
162+
163+
// The issue refers to an ungenerated message in the map
164+
message DemoResp {
165+
map<int32, DemoState> demoState = 1;
166+
int64 pramsArea = 2;
167+
bool paramsSeason = 3;
168+
}
169+
170+
171+
message DemoState {
172+
int64 paramsDID = 4;
173+
}

example/proto_3_20_pydanticv1/demo_gen_code.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -25,6 +25,16 @@ class SubMessage(BaseModel):
2525
field2: SubMessage = Field(default_factory=SubMessage)
2626

2727

28+
class DemoState(BaseModel):
29+
paramsDID: int = Field(default=0)
30+
31+
32+
class DemoResp(BaseModel):
33+
demoState: typing.Dict[int, DemoState] = Field(default_factory=dict)
34+
pramsArea: int = Field(default=0)
35+
paramsSeason: bool = Field(default=False)
36+
37+
2838
class EmptyMessage(BaseModel):
2939
pass
3040

example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -28,6 +28,16 @@ class SubMessage(BaseModel):
2828
field2: SubMessage = Field(default_factory=SubMessage)
2929

3030

31+
class DemoState(BaseModel):
32+
paramsDID: int = Field(default=0)
33+
34+
35+
class DemoResp(BaseModel):
36+
demoState: typing.Dict[int, DemoState] = Field(default_factory=dict)
37+
pramsArea: int = Field(default=0)
38+
paramsSeason: bool = Field(default=False)
39+
40+
3141
class EmptyMessage(BaseModel):
3242
pass
3343

example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -28,6 +28,16 @@ class SubMessage(BaseModel):
2828
field2: SubMessage = Field(default_factory=SubMessage)
2929

3030

31+
class DemoState(BaseModel):
32+
paramsDID: int = Field(default=0)
33+
34+
35+
class DemoResp(BaseModel):
36+
demoState: typing.Dict[int, DemoState] = Field(default_factory=dict)
37+
pramsArea: int = Field(default=0)
38+
paramsSeason: bool = Field(default=False)
39+
40+
3141
class EmptyMessage(BaseModel):
3242
pass
3343

example/proto_3_20_pydanticv1/example/example_proto/common/single_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
from enum import IntEnum

example/proto_3_20_pydanticv1/example/example_proto/demo/alias_demo_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -57,8 +57,8 @@ class MapMessage(BaseModel):
5757
test map message and bad message
5858
"""
5959

60-
user_map: typing.Optional[typing.Dict[str, UserMessage]] = Field(default_factory=dict)
61-
user_flag: typing.Optional[typing.Dict[str, bool]] = Field(default_factory=dict)
60+
user_map: typing.Optional["typing.Dict[str, UserMessage]"] = Field(default_factory=dict)
61+
user_flag: typing.Optional["typing.Dict[str, bool]"] = Field(default_factory=dict)
6262

6363

6464
class RepeatedMessage(BaseModel):
@@ -93,8 +93,8 @@ class IncludeEnum(IntEnum):
9393
one = 1
9494
two = 2
9595

96-
user_list_map: typing.Optional[typing.Dict[str, RepeatedMessage]] = Field(default_factory=dict)
97-
user_map: typing.Optional[typing.Dict[str, MapMessage]] = Field(default_factory=dict)
96+
user_list_map: typing.Optional["typing.Dict[str, RepeatedMessage]"] = Field(default_factory=dict)
97+
user_map: typing.Optional["typing.Dict[str, MapMessage]"] = Field(default_factory=dict)
9898
user_pay: typing.Optional["NestedMessage.UserPayMessage"] = Field(
9999
default_factory=lambda: NestedMessage.UserPayMessage()
100100
)
@@ -128,7 +128,7 @@ class OptionalMessage(BaseModel):
128128
age: typing.Optional[int] = Field(default=0)
129129
item: typing.Optional[InvoiceItem] = Field(default_factory=InvoiceItem)
130130
str_list: typing.Optional[typing.List[str]] = Field(default_factory=list)
131-
int_map: typing.Optional[typing.Dict[str, int]] = Field(default_factory=dict)
131+
int_map: typing.Optional["typing.Dict[str, int]"] = Field(default_factory=dict)
132132
default_template_test: typing.Optional[float] = Field(default=1600000000.0)
133133

134134

example/proto_3_20_pydanticv1/example/example_proto/demo/demo_p2p.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.1](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -53,8 +53,8 @@ class MapMessage(BaseModel):
5353
test map message and bad message
5454
"""
5555

56-
user_map: typing.Dict[str, UserMessage] = Field(default_factory=dict)
57-
user_flag: typing.Dict[str, bool] = Field(default_factory=dict)
56+
user_map: "typing.Dict[str, UserMessage]" = Field(default_factory=dict)
57+
user_flag: "typing.Dict[str, bool]" = Field(default_factory=dict)
5858

5959

6060
class RepeatedMessage(BaseModel):
@@ -87,8 +87,8 @@ class IncludeEnum(IntEnum):
8787
one = 1
8888
two = 2
8989

90-
user_list_map: typing.Dict[str, RepeatedMessage] = Field(default_factory=dict)
91-
user_map: typing.Dict[str, MapMessage] = Field(default_factory=dict)
90+
user_list_map: "typing.Dict[str, RepeatedMessage]" = Field(default_factory=dict)
91+
user_map: "typing.Dict[str, MapMessage]" = Field(default_factory=dict)
9292
user_pay: "NestedMessage.UserPayMessage" = Field(default_factory=lambda: NestedMessage.UserPayMessage())
9393
include_enum: "NestedMessage.IncludeEnum" = Field(default=0)
9494
empty: None = Field()
@@ -120,7 +120,7 @@ class OptionalMessage(BaseModel):
120120
age: typing.Optional[int] = Field(default=0)
121121
item: typing.Optional[InvoiceItem] = Field(default_factory=InvoiceItem)
122122
str_list: typing.List[str] = Field(default_factory=list)
123-
int_map: typing.Dict[str, int] = Field(default_factory=dict)
123+
int_map: "typing.Dict[str, int]" = Field(default_factory=dict)
124124
default_template_test: float = Field(default=1600000000.0)
125125

126126

@@ -170,14 +170,28 @@ class TestSameName0(BaseModel):
170170

171171
class Body(BaseModel):
172172
input_model: str = Field(default="")
173-
input_info: typing.Dict[str, str] = Field(default_factory=dict)
173+
input_info: "typing.Dict[str, str]" = Field(default_factory=dict)
174174

175175
body: "TestSameName0.Body" = Field(default_factory=lambda: TestSameName0.Body())
176176

177177

178178
class TestSameName1(BaseModel):
179179
class Body(BaseModel):
180180
output_model: str = Field(default="")
181-
output_info: typing.Dict[str, str] = Field(default_factory=dict)
181+
output_info: "typing.Dict[str, str]" = Field(default_factory=dict)
182182

183183
body: "TestSameName1.Body" = Field(default_factory=lambda: TestSameName1.Body())
184+
185+
186+
class DemoResp(BaseModel):
187+
"""
188+
The issue refers to an ungenerated message in the map
189+
"""
190+
191+
demoState: "typing.Dict[int, DemoState]" = Field(default_factory=dict)
192+
pramsArea: int = Field(default=0)
193+
paramsSeason: bool = Field(default=False)
194+
195+
196+
class DemoState(BaseModel):
197+
paramsDID: int = Field(default=0)

0 commit comments

Comments
 (0)