Skip to content

Commit 66c8a3a

Browse files
authored
Merge pull request #84 from so1n/83-conversion-fails-to-check-for-imports-for-types-inside-map
83 conversion fails to check for imports for types inside map
2 parents 90498ba + b6fd9b5 commit 66c8a3a

File tree

91 files changed

+1018
-88
lines changed

Some content is hidden

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

91 files changed

+1018
-88
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
syntax = "proto3";
2+
package diff_pkg_refer_1;
3+
4+
message Demo1{};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
syntax = "proto3";
2+
import "example/example_proto/demo/diff_pkg_refer_1.proto";
3+
4+
package diff_pkg_refer_2;
5+
6+
message Demo2{
7+
map<string, diff_pkg_refer_1.Demo1> myField = 1;
8+
};

example/gen_simple_code.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@
1616
else:
1717
target_p += "_pydanticv2"
1818

19-
module = importlib.import_module(f"example.{target_p}.example.example_proto.demo.demo_pb2")
19+
module_list = [
20+
importlib.import_module(f"example.{target_p}.example.example_proto.demo.demo_pb2"),
21+
importlib.import_module(f"example.{target_p}.example.example_proto.demo.diff_pkg_refer_1_pb2"),
22+
importlib.import_module(f"example.{target_p}.example.example_proto.demo.diff_pkg_refer_2_pb2"),
23+
]
2024
message_class_list = []
21-
for module_name in dir(module):
22-
message_class = getattr(module, module_name)
23-
if not inspect.isclass(message_class):
24-
continue
25-
if not issubclass(message_class, Message):
26-
continue
27-
message_class_list.append(message_class)
25+
for module in module_list:
26+
for module_name in dir(module):
27+
message_class = getattr(module, module_name)
28+
if not inspect.isclass(message_class):
29+
continue
30+
if not issubclass(message_class, Message):
31+
continue
32+
message_class_list.append(message_class)
2833

2934
now_path: pathlib.Path = pathlib.Path(__file__).absolute()
3035

example/proto_3_20_pydanticv1/demo_gen_code.py

Lines changed: 14 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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -159,3 +159,16 @@ class Body(BaseModel):
159159
output_info: typing.Dict[str, str] = Field(default_factory=dict)
160160

161161
body: Body = Field()
162+
163+
164+
class Demo1(BaseModel):
165+
pass
166+
167+
168+
class ExampleExampleProtoDemoDiffPkgRefer1Demo1(BaseModel):
169+
"""Note: The current class does not belong to the package
170+
ExampleExampleProtoDemoDiffPkgRefer1Demo1 protobuf path:example/example_proto/demo/diff_pkg_refer_1.proto"""
171+
172+
173+
class Demo2(BaseModel):
174+
myField: typing.Dict[str, ExampleExampleProtoDemoDiffPkgRefer1Demo1] = Field(default_factory=dict)

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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](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: 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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](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_pyi.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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](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/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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](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[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.0.3](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

0 commit comments

Comments
 (0)